/** * Converts a UTF-8 string to an array. * @see http://php.net/str_split * * @author Harry Fuecks <*****@*****.**> * * @param string input string * @param integer maximum length of each chunk * @return array */ public static function str_split($str, $split_length = 1) { if (!isset(self::$called[__FUNCTION__])) { require SYSPATH . 'core/utf8/' . __FUNCTION__ . EXT; // Function has been called self::$called[__FUNCTION__] = TRUE; } return _str_split($str, $split_length); }
/** * Converts a UTF-8 string to an array. * @see http://php.net/str_split * * @author Harry Fuecks <*****@*****.**> * * @param string input string * @param integer maximum length of each chunk * @return array */ public static function str_split($str, $split_length = 1) { require_once dirname(__FILE__) . '/' . __FUNCTION__ . '.php'; return _str_split($str, $split_length); }
public static function str_split($str, $split_length = 1) { if (!isset(UTF8::$called[__FUNCTION__])) { require JsonApiApplication::find_file("utf8", __FUNCTION__); // Function has been called UTF8::$called[__FUNCTION__] = TRUE; } return _str_split($str, $split_length); }
# ------------------------------------ Same Days Conflict Start ------------------------------------------ # $mp_RET = DBGet(DBQuery('SELECT cp.MP,cp.MARKING_PERIOD_ID,cpv.DAYS,cpv.PERIOD_ID,cp.MARKING_PERIOD_ID,cp.TOTAL_SEATS,COALESCE(cp.FILLED_SEATS,0) AS FILLED_SEATS FROM course_periods cp,course_period_var cpv WHERE cp.COURSE_PERIOD_ID=\'' . $_SESSION['MassSchedule.php']['course_period_id'] . '\' AND cp.COURSE_PERIOD_ID=cpv.COURSE_PERIOD_ID')); $mps = GetAllMP(GetMPTable(GetMP($mp_RET[1]['MARKING_PERIOD_ID'], 'TABLE')), $mp_RET[1]['MARKING_PERIOD_ID']); $period_RET = DBGet(DBQuery('SELECT cpv.DAYS FROM schedule s,course_periods cp,course_period_var cpv WHERE cp.COURSE_PERIOD_ID=s.COURSE_PERIOD_ID AND s.STUDENT_ID=\'' . $student_id . '\' AND cp.COURSE_PERIOD_ID=cpv.COURSE_PERIOD_ID AND cpv.PERIOD_ID=\'' . $mp_RET[1]['PERIOD_ID'] . '\' AND s.MARKING_PERIOD_ID IN (' . $mps . ') AND (s.END_DATE IS NULL OR \'' . $convdate . '\'<=s.END_DATE)')); $ig_scheld = DBGet(DBQuery('SELECT IGNORE_SCHEDULING FROM school_periods WHERE PERIOD_ID=\'' . $mp_RET[1]['PERIOD_ID'] . '\' AND SCHOOL_ID=\'' . UserSchool() . '\'')); $sql_dupl = 'SELECT COURSE_PERIOD_ID FROM schedule WHERE STUDENT_ID = \'' . $student_id . '\' AND COURSE_PERIOD_ID = \'' . $_SESSION['MassSchedule.php']['course_period_id'] . '\' AND (END_DATE IS NULL OR (\'' . $convdate . '\' BETWEEN START_DATE AND END_DATE)) AND SCHOOL_ID=\'' . UserSchool() . '\''; $rit_dupl = DBQuery($sql_dupl); $count_entry = mysql_num_rows($rit_dupl); $days_conflict = false; if ($count_entry < 1 && $ig_scheld[1]['IGNORE_SCHEDULING'] != 'Y') { foreach ($period_RET as $existing) { if (strlen($mp_RET[1]['DAYS']) + strlen($existing['DAYS']) > 7) { $days_conflict = true; break; } else { foreach (_str_split($mp_RET[1]['DAYS']) as $i) { if (strpos($existing['DAYS'], $i) !== false) { $days_conflict = true; break 2; } } } } } if ($count_entry >= 1) { $days_conflict = true; } if ($days_conflict) { $select_stu_RET = DBGet(DBQuery('SELECT FIRST_NAME,LAST_NAME FROM students WHERE STUDENT_ID=\'' . $student_id . '\'')); $select_stu = $select_stu_RET[1]['FIRST_NAME'] . " " . $select_stu_RET[1]['LAST_NAME']; $period_res .= $select_stu . "<br>";
function VerifySchedule(&$schedule) { $conflicts = array(); $ij = count($schedule); for ($i = 1; $i < $ij; $i++) { for ($j = $i + 1; $j <= $ij; $j++) { if (!$conflicts[$i] || !$conflicts[$j]) { // the following two if's are equivalent, the second matches the 'Add a Course' logic, the first is the demorgan equivalent and easier to follow // if -not- marking periods don't overlap -or- dates don't overlap (i ends and j starts after i -or- j ends and i starts after j) then check further //if(! (strpos(GetAllMP(GetMPTable(GetMP($schedule[$i]['MARKING_PERIOD_ID'],'TABLE')),$schedule[$i]['MARKING_PERIOD_ID']),"'".$schedule[$j]['MARKING_PERIOD_ID']."'")===false //|| $schedule[$i]['END_EPOCH'] && $schedule[$j]['START_EPOCH']>$schedule[$i]['END_EPOCH'] || $schedule[$j]['END_EPOCH'] && $schedule[$i]['START_EPOCH']>$schedule[$j]['END_EPOCH'])) // if marking periods overlap -and- dates overlap (i doesn't end or j starts before i ends -and- j doesn't end or i starts before j ends) check further if (strpos(GetAllMP(GetMPTable(GetMP($schedule[$i]['MARKING_PERIOD_ID'], 'TABLE')), $schedule[$i]['MARKING_PERIOD_ID']), "'" . $schedule[$j]['MARKING_PERIOD_ID'] . "'") !== false && (!$schedule[$i]['END_EPOCH'] || $schedule[$j]['START_EPOCH'] <= $schedule[$i]['END_EPOCH']) && (!$schedule[$j]['END_EPOCH'] || $schedule[$i]['START_EPOCH'] <= $schedule[$j]['END_EPOCH'])) { // should not be enrolled in the same course with overlapping marking periods and dates if ($schedule[$i]['COURSE_ID'] == $schedule[$j]['COURSE_ID']) { //&& $schedule[$i]['COURSE_WEIGHT']==$schedule[$j]['COURSE_WEIGHT']) $conflicts[$i] = $conflicts[$j] = true; } else { // if different periods then okay if ($schedule[$i]['PERIOD_ID'] == $schedule[$j]['PERIOD_ID']) { // should not be enrolled in the same period on the same day if (strlen($schedule[$i]['DAYS']) + strlen($schedule[$j]['DAYS']) > 7) { $conflicts[$i] = $conflicts[$j] = true; } else { foreach (_str_split($schedule[$i]['DAYS']) as $k) { if (strpos($schedule[$j]['DAYS'], $k) !== false) { $conflicts[$i] = $conflicts[$j] = true; break; } } } } } } } } } foreach ($conflicts as $i => $true) { $schedule[$i]['TITLE'] = '<FONT color=red>' . $schedule[$i]['TITLE'] . '</FONT>'; } }
/** * Converts a UTF-8 string to an array * * This is a UTF8-aware version of [str_split](http://php.net/str_split). * * Example: * ~~~ * $array = UTF8::str_split($str); * ~~~ * * @author Harry Fuecks <*****@*****.**> * * @param string $str Input string * @param integer $split_length Maximum length of each chunk [Optional] * * @return array * * @uses Kohana::find_file */ public static function str_split($str, $split_length = 1) { UTF8::_load(__FUNCTION__); return _str_split($str, $split_length); }
function VerifySchedule(&$schedule) { $conflicts = array(); $ij = count($schedule); for ($i = 1; $i < $ij; $i++) { for ($j = $i + 1; $j <= $ij; $j++) { if (!$conflicts[$i] || !$conflicts[$j]) { if (strpos(GetAllMP(GetMPTable(GetMP($schedule[$i]['MARKING_PERIOD_ID'], 'TABLE')), $schedule[$i]['MARKING_PERIOD_ID']), "'" . $schedule[$j]['MARKING_PERIOD_ID'] . "'") !== false && (!$schedule[$i]['END_EPOCH'] || $schedule[$j]['START_EPOCH'] <= $schedule[$i]['END_EPOCH']) && (!$schedule[$j]['END_EPOCH'] || $schedule[$i]['START_EPOCH'] <= $schedule[$j]['END_EPOCH'])) { if ($schedule[$i]['COURSE_ID'] == $schedule[$j]['COURSE_ID']) { //&& $schedule[$i]['COURSE_WEIGHT']==$schedule[$j]['COURSE_WEIGHT']) $conflicts[$i] = $conflicts[$j] = true; } else { if ($schedule[$i]['PERIOD_ID'] == $schedule[$j]['PERIOD_ID']) { if (strlen($schedule[$i]['DAYS']) + strlen($schedule[$j]['DAYS']) > 7) { $conflicts[$i] = $conflicts[$j] = true; } else { foreach (_str_split($schedule[$i]['DAYS']) as $k) { if (strpos($schedule[$j]['DAYS'], $k) !== false) { $conflicts[$i] = $conflicts[$j] = true; break; } } } } } } } } } foreach ($conflicts as $i => $true) { $schedule[$i]['TITLE'] = '<FONT color=red>' . $schedule[$i]['TITLE'] . '</FONT>'; } }
/** * Converts a UTF-8 string to an array. This is a UTF8-aware version of * [str_split](http://php.net/str_split). * * $array = UTF8::str_split($str); * * @author Harry Fuecks <*****@*****.**> * * @param string $str input string * @param integer $split_length maximum length of each chunk * * @return array */ public static function str_split($str, $split_length = 1) { if (!isset(UTF8::$called[__FUNCTION__])) { require Kohana::find_file('utf8', __FUNCTION__); // Function has been called UTF8::$called[__FUNCTION__] = true; } return _str_split($str, $split_length); }