/** * Removes hook for parsecode. * * @since 1.0.0 * @uses $parsecode_tags * * @param string $tag parsecode tag to remove hook for. */ function remove_parsecode($tag) { global $parsecode_tags; if ('' == _trim($tag)) { $message = _t('Invalid parsecode name: empty name given.'); _incorrectly_called(__FUNCTION__, $message, '6.2.0'); return; } unset($parsecode_tags[$tag]); }
/** * is_ferpa function added to check for * active FERPA restrictions for students. * * @since 4.5 * @param int $id * Student's ID. */ function is_ferpa($id) { if ('' == _trim($id)) { $message = _t('Invalid student ID: empty ID given.'); _incorrectly_called(__FUNCTION__, $message, '6.2.0'); return; } if (!is_numeric($id)) { $message = _t('Invalid student ID: student id must be numeric.'); _incorrectly_called(__FUNCTION__, $message, '6.2.0'); return; } $app = \Liten\Liten::getInstance(); $ferpa = $app->db->query("SELECT\n rstrID\n FROM restriction\n WHERE stuID = ?\n AND rstrCode = 'FERPA'\n AND (endDate = '' OR endDate = '0000-00-00')", [$id]); $q = $ferpa->find(function ($data) { $array = []; foreach ($data as $d) { $array[] = $d; } return $array; }); if (count($q) > 0) { return _t('Yes'); } else { return _t('No'); } }
/** * Wrapper function for Hooks::do_action() and * executes functions hooked on a specific action hook. * * @since 6.0.03 * @deprecated since 6.2.0 * @param string $hook * The name of the action which should be executed. * @param mixed $arg * Additional arguments passed to functions hooked to the action. * @return mixed|null */ function do_action($hook, $arg = '') { if ('' == _trim($hook)) { $message = _t('Invalid do_action hook: empty hook name given.'); _incorrectly_called(__FUNCTION__, $message, '6.2.0'); return; } if (!is_string($hook)) { $message = _t('Invalid do_action hook: hook name must be a string.'); _incorrectly_called(__FUNCTION__, $message, '6.2.0'); return; } $app = \Liten\Liten::getInstance(); return $app->hook->do_action($hook, $arg); }
/** * Shows selected person's initials instead of * his/her's full name. * * @since 4.1.6 * @param int $ID * Person ID * @param int $initials * Number of initials to show. * @return string */ function get_initials($ID, $initials = 2) { if ('' == _trim($ID)) { $message = _t('Invalid person ID: empty ID given.'); _incorrectly_called(__FUNCTION__, $message, '6.2.0'); return; } if (!is_numeric($ID)) { $message = _t('Invalid person ID: person id must be numeric.'); _incorrectly_called(__FUNCTION__, $message, '6.2.0'); return; } $name = get_person_by('personID', $ID); if ($initials == 2) { return mb_substr(_h($name->fname), 0, 1, 'UTF-8') . '. ' . mb_substr(_h($name->lname), 0, 1, 'UTF-8') . '.'; } else { return _h($name->lname) . ', ' . mb_substr(_h($name->fname), 0, 1, 'UTF-8') . '.'; } }
/** * Performs a check within a php script and returns any other files * that might have been required or included. * * @since 6.2.0 * @param string $file_name * PHP script to check. */ function etsis_php_check_includes($file_name) { if ('' == _trim($file_name)) { $message = _t('Invalid file name: empty file name given.'); _incorrectly_called(__FUNCTION__, $message, '6.2.0'); return; } // NOTE that any file coming into this function has already passed the syntax check, so // we can assume things like proper line terminations $includes = []; // Get the directory name of the file so we can prepend it to relative paths $dir = dirname($file_name); // Split the contents of $fileName about requires and includes // We need to slice off the first element since that is the text up to the first include/require $requireSplit = array_slice(preg_split('/require|include/i', _file_get_contents($file_name)), 1); // For each match foreach ($requireSplit as $string) { // Substring up to the end of the first line, i.e. the line that the require is on $string = substr($string, 0, strpos($string, ";")); // If the line contains a reference to a variable, then we cannot analyse it // so skip this iteration if (strpos($string, "\$") !== false) { continue; } // Split the string about single and double quotes $quoteSplit = preg_split('/[\'"]/', $string); // The value of the include is the second element of the array // Putting this in an if statement enforces the presence of '' or "" somewhere in the include // includes with any kind of run-time variable in have been excluded earlier // this just leaves includes with constants in, which we can't do much about if ($include = $quoteSplit[1]) { // If the path is not absolute, add the dir and separator // Then call realpath to chop out extra separators if (strpos($include, ':') === FALSE) { $include = realpath($dir . DS . $include); } array_push($includes, $include); } } return $includes; }