Created
January 17, 2013 18:42
-
-
Save ienliven/4558452 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/cms/moodle/mod/ibis/lib.php b/src/cms/moodle/mod/ibis/lib.php | |
index f99fb0e..37e14c1 100644 | |
--- a/src/cms/moodle/mod/ibis/lib.php | |
+++ b/src/cms/moodle/mod/ibis/lib.php | |
@@ -1210,18 +1210,75 @@ | |
/** | |
* EXTENDED DUE DATE FUNCTIONS | |
*/ | |
+ function get_assignment_id_from_cmid($cmid) { | |
+ if (!$cm = get_record('course_modules', 'id', $cmid)) | |
+ throw new Exception('EDD: Course Module ID was incorrect'); | |
+ | |
+ if (!$ibis = get_record('ibis', 'id', $cm->instance)) | |
+ throw new Exception('EDD: ibis ID was incorrect'); | |
+ | |
+ return $ibis->id; | |
+ } | |
+ | |
+ function groups_get_users_without_group($courseid) { | |
+ | |
+ $sql = "SELECT usr.id,usr.firstname, usr.lastname, usr.email | |
+ FROM course c | |
+ INNER JOIN context cx ON c.id = cx.instanceid | |
+ AND cx.contextlevel = '50' AND c.id = $courseid | |
+ INNER JOIN role_assignments ra ON cx.id = ra.contextid | |
+ INNER JOIN role r ON ra.roleid = r.id | |
+ INNER JOIN user usr ON ra.userid = usr.id | |
+ WHERE r.name = 'Student' AND | |
+ usr.id NOT IN( | |
+ select gm.userid | |
+ from groups_members gm | |
+ INNER JOIN groups g ON g.id = gm.groupid | |
+ WHERE | |
+ g.courseid = $courseid | |
+ ) | |
+ ORDER BY usr.firstname"; | |
+ | |
+ return get_records_sql($sql); | |
+ } | |
function edd_create_edd($data) { | |
global $CFG; | |
+ error_log('edd_create_edd()'); | |
$my_time = time(); | |
- $sql = "INSERT INTO ibis_extended_due_dates VALUES (NULL, $data->course_modules_id, $data->user_id, $my_time, $my_time, $data->timeext) ON DUPLICATE KEY UPDATE timemodified = $my_time, timeext = $data->timeext"; | |
- $result = QDB::run("cms", $sql); | |
- if(!$result){ | |
+ $mysqli = new mysqli($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname); | |
+ | |
+ if ($mysqli->connect_error) { | |
+ error_log('Failed to connect to edd server'); | |
+ return false; | |
+ } | |
+ | |
+ //Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings (REMOVE GROUP INFO) | |
+ //Redmine Bug #1346 - Moodle-Ibis Integration: Something Weird in Extensions and Offsets | |
+ $eddGet = get_record_sql("select * from ibis_extended_due_dates where course_modules_id = $data->course_modules_id and user_id = $data->user_id"); | |
+ | |
+ if ($eddGet) { | |
+ $eddGet->timemodified = $my_time; | |
+ $eddGet->timeext = $data->timeext; | |
+ | |
+ $sql = "update ibis_extended_due_dates set timemodified = $my_time, timeext = $data->timeext where id = $eddGet->id"; | |
+ } else { | |
+ $sql = 'insert into ibis_extended_due_dates values (NULL, ' . $data->course_modules_id . ',' . $data->user_id . ',' . $my_time . ',' . $my_time . ',' . $data->timeext . ')'; | |
+ } | |
+ | |
+ $result = $mysqli->query($sql); | |
+ | |
+ //End - Redmine Feature #1346 | |
+ | |
+ if ($result === false or ( $mysqli->affected_rows != 1 and $mysqli->affected_rows != 2)) { | |
+ error_log('Failed SQL Statement - insert or update edd - ' . $sql); | |
return false; | |
} | |
+ $id = $mysqli->insert_id; | |
+ | |
try { | |
require_once $CFG->dirroot . '/mod/ibis/grade/GradebookDueDateUpdater.php'; | |
$updater = new GradebookDueDateUpdater($data->course_modules_id); | |
@@ -1235,13 +1292,122 @@ | |
return true; | |
} | |
- function edd_remove_edd($id) { | |
+ function edd_update_edd($data) { | |
+ global $CFG; | |
+ | |
+ $data->timemodified = time(); | |
+ | |
+ error_log('edd_update_edd()'); | |
+ | |
+ $id = update_record('ibis_extended_due_dates', $data); | |
+ | |
+ try { | |
+ require_once $CFG->dirroot . '/mod/ibis/grade/GradebookDueDateUpdater.php'; | |
+ $updater = new GradebookDueDateUpdater($data->course_modules_id); | |
+ $updater->updateGradebookDueDateUser($data->user_id, $data->timeext); | |
+ } catch (Exception $e) { | |
+ $msg = 'mod ibis lib error updating edd: ' . $e->getMessage(); | |
+ error_log($msg); | |
+ return false; | |
+ } | |
+ return $id; | |
+ } | |
+ | |
+ function edd_remove_edds($data) { | |
+ global $CFG; | |
+ | |
+ error_log('edd_remove_edds()'); | |
+ | |
+ // find user ids for updating grades. | |
+ $sql = "select id, user_id from ibis_extended_due_dates where course_modules_id = $data->course_modules_id and timeext = $data->timeext"; | |
+ $users = get_records_sql($sql); | |
+ | |
+ //Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings | |
+ $id = delete_records_select('ibis_extended_due_dates', "course_modules_id = $data->course_modules_id and timeext = $data->timeext"); | |
+ | |
+ if (!empty($users)) { | |
+ $my_users = array(); | |
+ foreach ($users as $user) | |
+ $my_users[] = $user->user_id; | |
+ | |
+ $userids = implode(",", $my_users); | |
+ | |
+ try { | |
+ require_once $CFG->dirroot . '/mod/ibis/grade/GradebookDueDateUpdater.php'; | |
+ $updater = new GradebookDueDateUpdater($data->course_modules_id); | |
+ $updater->resetGradebookDueDateUsers($userids); | |
+ } catch (Exception $e) { | |
+ $msg = 'mod ibis lib error removing edds: ' . $e->getMessage(); | |
+ error_log($msg); | |
+ return false; | |
+ } | |
+ } | |
+ | |
+ if ($id) { | |
+ return 1; | |
+ } else { | |
+ return 0; | |
+ } | |
+ } | |
+ | |
+ function edd_remove_edd($id) { // where is this used? | |
+ global $CFG; | |
+ | |
+ error_log('edd_remove_edd()'); | |
+ | |
$id = delete_records('ibis_extended_due_dates', 'id', $id); | |
return $id; | |
} | |
+ function edd_remove_user($list) { | |
+ global $CFG; | |
+ | |
+ error_log('edd_remove_user()'); | |
+ | |
+ $mysqli = new mysqli($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname); | |
+ | |
+ if ($mysqli->connect_error) { | |
+ error_log('Failed to connect to edd server'); | |
+ return false; | |
+ } | |
+ | |
+ // find course_modules.id for the list of users | |
+ // assumes all users in list have same course_module_id.... how could they not? | |
+ $sql = 'select course_modules_id from ibis_extended_due_dates where id = ' . $list[0]; | |
+ $result = $mysqli->query($sql); | |
+ $obj = $result->fetch_object(); | |
+ $cmid = $obj->course_modules_id; | |
+ | |
+ // find the list of userids from this list of ibis extended due dates ids | |
+ $extended_due_dates_ids = implode(",", $list); | |
+ $sql = 'select user_id from ibis_extended_due_dates where id in (' . $extended_due_dates_ids . ')'; | |
+ $users = get_records_sql($sql); | |
+ $my_users = array(); | |
+ foreach ($users as $user) | |
+ $my_users[] = $user->user_id; | |
+ | |
+ $userids = implode(",", $my_users); | |
+ | |
+ // delete from ibis exended due dates | |
+ $id = delete_records_select('ibis_extended_due_dates', 'id in (' . $extended_due_dates_ids . ')'); | |
+ | |
+ try { | |
+ require_once $CFG->dirroot . '/mod/ibis/grade/GradebookDueDateUpdater.php'; | |
+ $updater = new GradebookDueDateUpdater($cmid); | |
+ $updater->resetGradebookDueDateUsers($userids); | |
+ } catch (Exception $e) { | |
+ $msg = 'mod ibis lib error edd remove user: ' . $e->getMessage(); | |
+ error_log($msg); | |
+ return false; | |
+ } | |
+ | |
+ return $id; | |
+ } | |
+ | |
function edd_get_individual_user_dates($courseid, $userid) { | |
- $sql = "SELECT * FROM ibis_extended_due_dates i WHERE course_modules_id = $courseid and user_id = $userid"; | |
+ $sql = "SELECT * FROM ibis_extended_due_dates i | |
+ where course_modules_id = $courseid and user_id = $userid"; | |
+ | |
return get_record_sql($sql); | |
} | |
@@ -1250,50 +1416,56 @@ | |
*/ | |
function edd_get_user_due_date($cmid, $userid) { | |
- //The business logic in this query is as follows: | |
- //Only one extension (group or individual) can be counted (first encountered if anomaly) | |
- //The result will be the original due date plus that extension | |
- //If there is an individual extension, STOP group extensions mean nothing | |
- //If no extensions are found, use original ibis due date | |
- | |
- $sql="SELECT I.timedue+IEDD.timeext AS exttimedue | |
- FROM cms.course_modules AS CM | |
- INNER JOIN cms.ibis_extended_due_dates AS IEDD | |
- ON IEDD.course_modules_id=CM.id | |
- INNER JOIN cms.ibis AS I | |
- ON I.id=CM.instance | |
- WHERE | |
- CM.id=?cmid? AND IEDD.user_id=?userid? | |
- UNION | |
- SELECT I.timedue+IGAD.timeext AS exttimedue | |
- FROM cms.course_modules AS CM | |
- INNER JOIN cms.groups as G | |
- ON G.courseid=CM.course | |
- INNER JOIN cms.groups_members as GM | |
- ON GM.groupid=G.id | |
- INNER JOIN cms.ibis_group_assignment_dates AS IGAD | |
- ON IGAD.coursemodulesid=CM.id AND IGAD.groupid=G.id | |
- INNER JOIN cms.ibis AS I | |
- ON I.id=CM.instance | |
- WHERE | |
- CM.id=?cmid? AND GM.userid=?userid? | |
- UNION | |
- SELECT I.timedue AS exttimedue | |
- FROM cms.course_modules AS CM | |
- INNER JOIN cms.ibis AS I | |
- ON I.id=CM.instance | |
- WHERE | |
- CM.id=?cmid? | |
- LIMIT 1"; | |
- | |
- $timedue = QDB::question("cms", $sql, array("cmid"=>$cmid, "userid"=>$userid), FALSE); | |
- | |
- if($timedue === FALSE){ | |
+ $cm = get_record('course_modules', 'id', $cmid); | |
+ if (empty($cm)) { | |
throw new Exception('Unable to find Course Module'); | |
} | |
- return $timedue; | |
+ $ibis = get_record('ibis', 'id', $cm->instance); | |
+ if (empty($ibis)) { | |
+ throw new Exception('unable to find ibis'); | |
+ } | |
+ | |
+ if ($ibis->timedue == 0) { | |
+ return 0; | |
+ } | |
+ | |
+ //Trying to get the individual | |
+ $individualEDD = get_record('ibis_extended_due_dates', 'course_modules_id', $cmid, 'user_id', $userid); | |
+ if ($individualEDD) { | |
+ return ($ibis->timedue + $individualEDD->timeext); | |
+ } | |
+ | |
+ //Bug #1626 - Moodle: Course 5870 Loads Super Slow | |
+ $groupUser = get_record_sql("SELECT g.id, g.timeext, g.offset FROM groups g, groups_members gm WHERE g.id = gm.groupid and g.courseid = $ibis->course and gm.userid = $userid"); | |
+ if ($groupUser) { | |
+ $groupcmEDD = get_record('ibis_group_assignment_dates', 'coursemodulesid', $cmid, 'groupid', $groupUser->id); | |
+ if ($groupcmEDD && $groupcmEDD->timeext != 0) { | |
+ return ($ibis->timedue + $groupcmEDD->timeext); | |
+ } | |
+ | |
+ if ($groupUser->timeext != 0) { | |
+ return ($ibis->timedue + $groupUser->timeext); | |
} | |
+ } | |
+ | |
+ return $ibis->timedue; | |
+ } | |
+ | |
+ function edd_get_all_users($course_id) { | |
+ | |
+ $sql = "SELECT usr.id,usr.firstname, usr.lastname, usr.email | |
+ FROM course c | |
+ INNER JOIN context cx ON c.id = cx.instanceid | |
+ AND cx.contextlevel = '50' AND c.id = $course_id | |
+ INNER JOIN role_assignments ra ON cx.id = ra.contextid | |
+ INNER JOIN role r ON ra.roleid = r.id | |
+ INNER JOIN user usr ON ra.userid = usr.id | |
+ WHERE r.name = 'Student' | |
+ ORDER BY usr.firstname"; | |
+ | |
+ return get_records_sql($sql); | |
+ } | |
/** | |
* END - EXTENDED DUE DATE FUNCTIONS | |
@@ -1304,25 +1476,161 @@ | |
* Feature #942 - Moodle-Ibis Integration: Apply Group Date Offset to All Dates | |
*/ | |
function oaf_create_oaf($data) { | |
+ global $CFG; | |
+ error_log('oaf_create_oaf()'); | |
$my_time = time(); | |
- $sql = "INSERT INTO ibis_offset_available_dates VALUES (NULL, $data->course_modules_id, $data->user_id, $my_time, $my_time, $data->timeext) ON DUPLICATE KEY UPDATE timemodified = $my_time, timeext = $data->timeext"; | |
- $result = QDB::run("cms", $sql); | |
- if(!$result){ | |
+ $mysqli = new mysqli($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname); | |
+ | |
+ if ($mysqli->connect_error) { | |
+ error_log('Failed to connect to edd server'); | |
+ return false; | |
+ } | |
+ | |
+ // Redmine Bug #1346 - Moodle-Ibis Integration: Something Weird in Extensions and Offsets | |
+ //Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings | |
+ $eddGet = get_record_sql("select * from ibis_offset_available_dates where course_modules_id = $data->course_modules_id and user_id = $data->user_id"); | |
+ | |
+ if ($eddGet) { | |
+ $eddGet->timemodified = $my_time; | |
+ $eddGet->timeext = $data->timeext; | |
+ | |
+ $sql = "update ibis_offset_available_dates set timemodified = $my_time, timeext = $data->timeext where id = $eddGet->id"; | |
+ } else { | |
+ $sql = 'insert into ibis_offset_available_dates values (NULL, ' . $data->course_modules_id . ',' . $data->user_id . ',' . $my_time . ',' . $my_time . ',' . $data->timeext . ')'; | |
+ } | |
+ | |
+ $result = $mysqli->query($sql); | |
+ | |
+ if ($result === false or ( $mysqli->affected_rows != 1 and $mysqli->affected_rows != 2)) { | |
+ error_log('Failed SQL Statement - insert or update edd - ' . $sql); | |
return false; | |
} | |
+ $id = $mysqli->insert_id; | |
+ | |
return true; | |
} | |
+ function oaf_update_oaf($data) { | |
+ global $CFG; | |
+ | |
+ $data->timemodified = time(); | |
+ error_log('oaf_update_oaf()'); | |
+ $id = update_record('ibis_offset_available_dates', $data); | |
+ | |
+ return $id; | |
+ } | |
+ | |
+ function oaf_remove_oafs($data) { | |
+ global $CFG; | |
+ | |
+ error_log('oaf_remove_oafs()'); | |
+ | |
+ $sql = "select id, user_id from ibis_offset_available_dates where course_modules_id = $data->course_modules_id and timeext = $data->timeext"; | |
+ $users = get_records_sql($sql); | |
+ | |
+ if ($data->groupid) { | |
+ $id = delete_records_select('ibis_offset_available_dates', "user_id = $data->user_id and groupid = $data->groupid"); | |
+ } else { | |
+ $id = delete_records_select('ibis_offset_available_dates', "course_modules_id = $data->course_modules_id and timeext = $data->timeext"); | |
+ } | |
+ | |
+ if ($id) { | |
+ return 1; | |
+ } else { | |
+ return 0; | |
+ } | |
+ } | |
+ | |
function oaf_remove_oaf($id) { | |
+ global $CFG; | |
+ | |
+ error_log('oaf_remove_oaf()'); | |
$id = delete_records('ibis_offset_available_dates', 'id', $id); | |
return $id; | |
} | |
+ function oaf_remove_user($list) { | |
+ global $CFG; | |
+ | |
+ error_log('oaf_remove_user()'); | |
+ | |
+ $mysqli = new mysqli($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname); | |
+ | |
+ if ($mysqli->connect_error) { | |
+ error_log('Failed to connect to edd server'); | |
+ return false; | |
+ } | |
+ | |
+ $sql = 'select course_modules_id from ibis_offset_available_dates where id = ' . $list[0]; | |
+ $result = $mysqli->query($sql); | |
+ $obj = $result->fetch_object(); | |
+ $cmid = $obj->course_modules_id; | |
+ | |
+ $offset_available_dates_ids = implode(",", $list); | |
+ $sql = 'select user_id from ibis_offset_available_dates where id in (' . $offset_available_dates_ids . ')'; | |
+ $users = get_records_sql($sql); | |
+ $my_users = array(); | |
+ foreach ($users as $user) | |
+ $my_users[] = $user->user_id; | |
+ | |
+ $id = delete_records_select('ibis_offset_available_dates', 'id in (' . $offset_available_dates_ids . ')'); | |
+ | |
+ return $id; | |
+ } | |
+ | |
+ function oaf_get_used_dates($courseid) { | |
+ $sql = "SELECT * FROM ibis_offset_available_dates i | |
+ where course_modules_id = $courseid | |
+ group by timeext"; | |
+ | |
+ return get_records_sql($sql); | |
+ } | |
+ | |
+ function oaf_get_individual_dates($courseid) { | |
+ $sql = "SELECT * FROM ibis_offset_available_dates i | |
+ where course_modules_id = $courseid"; | |
+ | |
+ return get_records_sql($sql); | |
+ } | |
+ | |
function oaf_get_individual_user_dates($courseid, $userid) { | |
- $sql = "SELECT * FROM ibis_offset_available_dates i WHERE course_modules_id = $courseid and user_id = $userid"; | |
+ $sql = "SELECT * FROM ibis_offset_available_dates i | |
+ where course_modules_id = $courseid and user_id = $userid"; | |
+ | |
+ return get_record_sql($sql); | |
+ } | |
+ | |
+ function oaf_get_users_by_timestamp($courseid, $timestamp) { | |
+ $sql = "SELECT usr.id,usr.firstname, usr.lastname, usr.email | |
+ FROM ibis_offset_available_dates i | |
+ INNER JOIN user usr ON i.user_id = usr.id | |
+ where course_modules_id = $courseid | |
+ and timeext = $timestamp"; | |
+ | |
+ return get_records_sql($sql); | |
+ } | |
+ | |
+ function oaf_get_used_users($courseid) { | |
+ return get_records("ibis_offset_available_dates", "course_modules_id", $courseid); | |
+ } | |
+ | |
+ function oaf_get_items($couseid, $timeext) { | |
+ $sql = "select * FROM ibis_offset_available_dates | |
+ where course_modules_id = $couseid | |
+ and timeext = $timeext"; | |
+ | |
+ return get_records_sql($sql); | |
+ } | |
+ | |
+ function oaf_get_item($couseid, $timeext, $userid) { | |
+ $sql = "select * FROM ibis_offset_available_dates | |
+ where course_modules_id = $couseid | |
+ and timeext = $timeext | |
+ and user_id = $userid"; | |
+ | |
return get_record_sql($sql); | |
} | |
@@ -1368,15 +1676,28 @@ | |
return $ibis->timeavailable; | |
} | |
+ function oaf_get_all_users($course_id) { | |
+ $sql = "SELECT usr.id,usr.firstname, usr.lastname, usr.email | |
+ FROM course c | |
+ INNER JOIN context cx ON c.id = cx.instanceid | |
+ AND cx.contextlevel = '50' AND c.id = $course_id | |
+ INNER JOIN role_assignments ra ON cx.id = ra.contextid | |
+ INNER JOIN role r ON ra.roleid = r.id | |
+ INNER JOIN user usr ON ra.userid = usr.id | |
+ WHERE r.name = 'Student' | |
+ ORDER BY usr.firstname"; | |
+ return get_records_sql($sql); | |
+ } | |
+ | |
/** | |
* END - AVAILABLE FROM OFFSET FUNCTIONS | |
*/ | |
- | |
/* | |
* Created for: Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings | |
*/ | |
function create_oaf_edd_group_dates($groupid, $cmid, $offset, $timeext) { | |
+ global $CFG; | |
$sqlGet = "select * from ibis_group_assignment_dates where groupid = $groupid and coursemodulesid = $cmid"; | |
$ibis_group_assignment_dates = get_record_sql($sqlGet); | |
@@ -1401,6 +1722,7 @@ | |
*/ | |
function create_oaf_edd_group_dates_ios($groupid, $cmid, $offset, $timeext) { | |
+ global $CFG; | |
$sqlGet = "select * from ibis_group_assignment_dates where groupid = $groupid and coursemodulesid = $cmid"; | |
$ibis_group_assignment_dates = get_record_sql($sqlGet); | |
@@ -1459,6 +1781,7 @@ | |
*/ | |
function update_oaf_edd_group_dates($groupid, $cmid, $offset, $timeext) { | |
+ global $CFG; | |
$sqlGet = "select * from ibis_group_assignment_dates where groupid = $groupid and coursemodulesid = $cmid"; | |
$ibis_group_assignment_dates = get_record_sql($sqlGet); | |
@@ -1480,6 +1803,7 @@ | |
*/ | |
function delete_oaf_edd_group_dates($groupid, $cmid, $type) { | |
+ global $CFG; | |
$sqlGet = "select * from ibis_group_assignment_dates where groupid = $groupid and coursemodulesid = $cmid"; | |
$ibis_group_assignment_dates = get_record_sql($sqlGet); | |
@@ -1531,11 +1855,19 @@ | |
* an assignment due date has passed are assigned zeros | |
*/ | |
function ibis_role_assign($userid, $context, $roleid) { | |
- $sql = "UPDATE grade_items LEFT JOIN course_modules ON course_modules.course = grade_items.courseid | |
- SET grade_items.lastduedateflush = 0 WHERE grade_items.courseid = $context->instanceid AND grade_items.itemtype = 'course'"; | |
- if(!QDB::run("cms", $sql)){ | |
- error_log("Failed calling the ibis_role_assign on assign roles for MOD/IBIS"); | |
+ global $CFG; | |
+ | |
+ $mysqli = new mysqli($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname); | |
+ | |
+ if ($mysqli->connect_error) { | |
+ error_log('Failed to connect in ibis_role_assign... should never happen'); | |
} | |
+ | |
+ // set cms.grade_items.lastduedateflush = 0 for the course to ensure that course totals are recalculated when gradebook is opened | |
+ $sql = 'update grade_items left join course_modules on course_modules.course = grade_items.courseid '; | |
+ $sql .= 'set grade_items.lastduedateflush = 0 where grade_items.courseid = ' . $context->instanceid . ' and grade_items.itemtype = "course"'; | |
+ | |
+ $mysqli->query($sql); | |
} | |
function isAssignmentComplete($userid, $ibisid) { | |
@@ -2047,50 +2379,6 @@ | |
* NEW GLOBAL MOD/IBIS UPDATE FUNCTIONS | |
*/ | |
- function getDiffDateTime($time1, $time2, $precision = 6) { | |
- if (!is_int($time1)) { | |
- $time1 = strtotime($time1); | |
- } | |
- if (!is_int($time2)) { | |
- $time2 = strtotime($time2); | |
- } | |
- | |
- if ($time1 > $time2) { | |
- $ttime = $time1; | |
- $time1 = $time2; | |
- $time2 = $ttime; | |
- } | |
- | |
- $intervals = array('days', 'hours', 'minutes'); | |
- $diffs = array(); | |
- | |
- foreach ($intervals as $interval) { | |
- $diffs[$interval] = 0; | |
- $ttime = strtotime("+1 ".$interval, $time1); | |
- while ($time2 >= $ttime) { | |
- $time1 = $ttime; | |
- $diffs[$interval]++; | |
- $ttime = strtotime("+1 ".$interval, $time1); | |
- } | |
- } | |
- | |
- $count = 0; | |
- $times = array(); | |
- | |
- foreach ($diffs as $interval => $value) { | |
- if ($count >= $precision) { | |
- break; | |
- } | |
- | |
- if ($value > 0) { | |
- $times[$interval] = $value; | |
- $count++; | |
- } | |
- } | |
- | |
- return $times; | |
- } | |
- | |
function updateSaplingAssignment($id, $title = null, $policySetID = null, $isbn = null){ | |
$ibis = get_record('ibis', 'id', $id); | |
if($ibis && ($title || $policySetID || $isbn)){ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment