本文整理汇总了PHP中ilUtil::now方法的典型用法代码示例。如果您正苦于以下问题:PHP ilUtil::now方法的具体用法?PHP ilUtil::now怎么用?PHP ilUtil::now使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilUtil
的用法示例。
在下文中一共展示了ilUtil::now方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateUsers
/**
* Generate Users
*
* @param
* @return
*/
function generateUsers($a_login_base = "learner", $a_start = 1, $a_end = 1000, $a_firstname = "John", $a_lastname_base = "Learner", $a_pw = "learnerpw", $a_email = "de@de.de", $a_gender = "m", $a_lang = "en")
{
global $rbacadmin;
// new users
$this->log("Creating Users");
for ($i = $a_start; $i <= $a_end; $i++) {
$this->log($a_login_base . $i);
$user = new ilObjUser();
$user->setLogin($a_login_base . $i);
$user->setFirstname($a_firstname);
$user->setLastname($a_lastname_base . " " . $i);
$user->setGender($a_gender);
$user->setEmail($a_email);
$user->setAgreeDate(ilUtil::now());
$user->setPasswd($a_pw, IL_PASSWD_PLAIN);
$user->setTitle($user->getFullname());
$user->setDescription($user->getEmail());
$user->setLastPasswordChangeTS(time());
$user->setActive(true);
$user->setTimeLimitUnlimited(true);
$user->create();
$user->setLanguage($a_lang);
$user->saveAsNew(false);
$user->writePrefs();
$rbacadmin->assignUser(4, $user->getId(), true);
}
}
示例2: addNewType
/**
* Add new type to object data
*
* @param string $a_type_id
* @param string $a_type_title
* @return int insert id
*/
public static function addNewType($a_type_id, $a_type_title)
{
global $ilDB;
// check if it already exists
$type_id = self::getObjectTypeId($a_type_id);
if ($type_id) {
return $type_id;
}
$type_id = $ilDB->nextId('object_data');
$fields = array('obj_id' => array('integer', $type_id), 'type' => array('text', 'typ'), 'title' => array('text', $a_type_id), 'description' => array('text', $a_type_title), 'owner' => array('integer', -1), 'create_date' => array('timestamp', ilUtil::now()), 'last_update' => array('timestamp', ilUtil::now()));
$ilDB->insert('object_data', $fields);
return $type_id;
}
示例3: scorm12PlayerUnload
function scorm12PlayerUnload()
{
global $ilUser, $ilDB;
$user_id = $ilUser->getID();
$ref_id = $_GET["ref_id"];
$obj_id = ilObject::_lookupObjId($ref_id);
if ($obj_id <= 1) {
$GLOBALS['ilLog']->write(__METHOD__ . ' no valid obj_id');
} else {
$data = $_POST['last_visited'];
// $GLOBALS['ilLog']->write(__METHOD__.' last_visited: '.$data);
if ($data) {
$set = $ilDB->queryF('
SELECT rvalue FROM scorm_tracking
WHERE user_id = %s
AND sco_id = %s
AND lvalue = %s
AND obj_id = %s', array('integer', 'integer', 'text', 'integer'), array($user_id, 0, 'last_visited', $obj_id));
if ($rec = $ilDB->fetchAssoc($set)) {
$ilDB->update('scorm_tracking', array('rvalue' => array('clob', $data), 'c_timestamp' => array('timestamp', ilUtil::now())), array('user_id' => array('integer', $user_id), 'sco_id' => array('integer', 0), 'lvalue' => array('text', 'last_visited'), 'obj_id' => array('integer', $obj_id)));
} else {
$ilDB->insert('scorm_tracking', array('obj_id' => array('integer', $obj_id), 'user_id' => array('integer', $user_id), 'sco_id' => array('integer', 0), 'lvalue' => array('text', 'last_visited'), 'rvalue' => array('clob', $data), 'c_timestamp' => array('timestamp', ilUtil::now())));
}
}
// update time and numbers of attempts in change event
//NOTE: here it is correct (not count of commit with changed values); be careful to performance issues
ilObjSCORMTracking::_syncReadEvent($obj_id, $user_id, "sahs", $ref_id);
}
header('Content-Type: text/plain; charset=UTF-8');
print "";
}
示例4: render
/**
* Creates the preview of the specified preview object.
*
* @param ilPreview $preview The preview object.
* @param ilObject $obj The object to create a preview for.
* @param bool $async true, if the rendering should be done asynchronously; otherwise, false.
* @return bool true, if the preview was successfully rendered; otherwise, false.
*/
public final function render($preview, $obj, $async)
{
$preview->setRenderDate(ilUtil::now());
$preview->setRenderStatus(ilPreview::RENDER_STATUS_PENDING);
$preview->save();
// TODO: this should be done in background if $async is true
// the deriving renderer should deliver images
require_once "./Services/Preview/classes/class.ilRenderedImage.php";
$images = $this->renderImages($obj);
// process each image
if (is_array($images) && count($images) > 0) {
$success = false;
foreach ($images as $idx => $image) {
// create the ending preview image
$success |= $this->createPreviewImage($image->getImagePath(), sprintf($preview->getFilePathFormat(), $idx + 1));
// if the image is temporary we can delete it
if ($image->isTemporary()) {
$image->delete();
}
}
$preview->setRenderDate(ilUtil::now());
$preview->setRenderStatus($success ? ilPreview::RENDER_STATUS_CREATED : ilPreview::RENDER_STATUS_FAILED);
return $success;
} else {
$preview->setRenderDate(ilUtil::now());
$preview->setRenderStatus(ilPreview::RENDER_STATUS_FAILED);
return false;
}
}
示例5: _getPresentationTitle
/**
* presentation title doesn't have to be page title, it may be
* chapter title + page title or chapter title only, depending on settings
*
* @param string $a_mode IL_CHAPTER_TITLE | IL_PAGE_TITLE | IL_NO_HEADER
*/
function _getPresentationTitle($a_pg_id, $a_mode = IL_CHAPTER_TITLE, $a_include_numbers = false, $a_time_scheduled_activation = false, $a_force_content = false)
{
global $ilDB;
// select
$query = "SELECT * FROM lm_data WHERE obj_id = " . $ilDB->quote($a_pg_id, "integer");
$pg_set = $ilDB->query($query);
$pg_rec = $ilDB->fetchAssoc($pg_set);
if ($a_mode == IL_NO_HEADER && !$a_force_content) {
return "";
}
$tree = new ilTree($pg_rec["lm_id"]);
$tree->setTableNames('lm_tree', 'lm_data');
$tree->setTreeTablePK("lm_id");
if ($a_mode == IL_PAGE_TITLE) {
$nr = "";
return $nr . $pg_rec["title"];
}
if ($tree->isInTree($pg_rec["obj_id"])) {
$pred_node = $tree->fetchPredecessorNode($pg_rec["obj_id"], "st");
$childs = $tree->getChildsByType($pred_node["obj_id"], "pg");
$cnt_str = "";
if (count($childs) > 1) {
$cnt = 0;
foreach ($childs as $child) {
include_once "./Services/COPage/classes/class.ilPageObject.php";
$active = ilPageObject::_lookupActive($child["obj_id"], ilObject::_lookupType($pg_rec["lm_id"]), $a_time_scheduled_activation);
if (!$active) {
$act_data = ilPageObject::_lookupActivationData((int) $child["obj_id"], ilObject::_lookupType($pg_rec["lm_id"]));
if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
$active = true;
}
}
if ($child["type"] != "pg" || $active) {
$cnt++;
}
if ($child["obj_id"] == $pg_rec["obj_id"]) {
$cur_cnt = $cnt;
}
}
if ($cnt > 1) {
$cnt_str = " (" . $cur_cnt . "/" . $cnt . ")";
}
}
require_once "./Modules/LearningModule/classes/class.ilStructureObject.php";
//$struct_obj =& new ilStructureObject($pred_node["obj_id"]);
//return $struct_obj->getTitle();
return ilStructureObject::_getPresentationTitle($pred_node["obj_id"], $a_include_numbers) . $cnt_str;
//return $pred_node["title"].$cnt_str;
} else {
return $pg_rec["title"];
}
}
示例6: importSuccess
function importSuccess($a_file)
{
global $ilDB, $ilUser;
include_once "./Services/Tracking/classes/class.ilLPStatus.php";
$scos = array();
//get all SCO's of this object ONLY RELEVANT!
include_once './Services/Object/classes/class.ilObjectLP.php';
$olp = ilObjectLP::getInstance($this->getId());
$collection = $olp->getCollectionInstance();
if ($collection) {
$scos = $collection->getItems();
}
$fhandle = fopen($a_file, "r");
$obj_id = $this->getID();
$users = array();
$fields = fgetcsv($fhandle, 4096, ';');
while (($csv_rows = fgetcsv($fhandle, 4096, ";")) !== FALSE) {
$data = array_combine($fields, $csv_rows);
//no check the format - sufficient to import users
if ($data["Login"]) {
$user_id = $this->get_user_id($data["Login"]);
}
if ($data["login"]) {
$user_id = $this->get_user_id($data["login"]);
}
//add mail in future
if ($data["user"] && is_int($data["user"])) {
$user_id = $data["user"];
}
if ($user_id > 0) {
$last_access = ilUtil::now();
if ($data['Date']) {
$date_ex = explode('.', $data['Date']);
$last_access = implode('-', array($date_ex[2], $date_ex[1], $date_ex[0]));
}
if ($data['LastAccess']) {
$last_access = $data['LastAccess'];
}
$status = ilLPStatus::LP_STATUS_COMPLETED_NUM;
// $users[] = $user_id;
if ($data["Status"]) {
if (is_int($data["Status"])) {
$status = $data["Status"];
} else {
if ($data["Status"] == ilLPStatus::LP_STATUS_NOT_ATTEMPTED) {
$status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM;
} else {
if ($data["Status"] == ilLPStatus::LP_STATUS_IN_PROGRESS) {
$status = ilLPStatus::LP_STATUS_IN_PROGRESS_NUM;
} else {
if ($data["Status"] == ilLPStatus::LP_STATUS_FAILED) {
$status = ilLPStatus::LP_STATUS_FAILED_NUM;
}
}
}
}
}
$attempts = null;
if ($data["Attempts"]) {
$attempts = $data["Attempts"];
}
$percentage_completed = 0;
if ($status == ilLPStatus::LP_STATUS_COMPLETED_NUM) {
$percentage_completed = 100;
}
if ($data['percentageCompletedSCOs']) {
$percentage_completed = $data['percentageCompletedSCOs'];
}
$sco_total_time_sec = null;
if ($data['SumTotal_timeSeconds']) {
$sco_total_time_sec = $data['SumTotal_timeSeconds'];
}
$this->importSuccessForSahsUser($user_id, $last_access, $status, $attempts, $percentage_completed, $sco_total_time_sec);
if ($status == ilLPStatus::LP_STATUS_COMPLETED_NUM) {
foreach ($scos as $sco_id) {
$res = $ilDB->queryF('
SELECT * FROM cmi_node WHERE cp_node_id = %s AND user_id = %s AND (completion_status = %s OR success_status = %s)', array('integer', 'integer', 'text', 'text'), array($sco_id, $user_id, 'completed', 'passed'));
if (!$ilDB->numRows($res)) {
$nextId = $ilDB->nextId('cmi_node');
$val_set = $ilDB->manipulateF('INSERT INTO cmi_node
(cp_node_id,user_id,completion_status,c_timestamp,cmi_node_id)
VALUES(%s,%s,%s,%s,%s)', array('integer', 'integer', 'text', 'timestamp', 'integer'), array($sco_id, $user_id, 'completed', $last_access, $nextId));
} else {
$ilDB->update('cmi_node', array('completion_status' => array('text', 'completed'), 'success_status' => array('text', ''), 'c_timestamp' => array('timestamp', $last_access)), array('user_id' => array('integer', $user_id), 'cp_node_id' => array('integer', $sco_id)));
}
}
}
} else {
//echo "Warning! User $csv_rows[0] does not exist in ILIAS. Data for this user was skipped.\n";
}
}
// update learning progress
include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
ilLPStatusWrapper::_refreshStatus($this->getId());
return 0;
}
示例7: isVisible
function isVisible($a_id, $a_type)
{
include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
$active = ilLMPage::_lookupActive($a_id, $this->lm_obj->getType(), $this->lm_set->get("time_scheduled_page_activation"));
if (!$active && $a_type == "pg") {
$act_data = ilLMPage::_lookupActivationData((int) $a_id, $this->lm_obj->getType());
if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
return true;
} else {
return false;
}
} else {
return true;
}
}
示例8: getLastNewsIdForContext
/**
* Get last news id of news set related to a certain context
*/
static function getLastNewsIdForContext($a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id = "", $a_context_sub_obj_type = "", $a_only_today = false)
{
global $ilDB;
// Determine how many rows should be deleted
$query = "SELECT id, update_date " . "FROM il_news_item " . "WHERE " . "context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") . " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") . " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") . " AND " . $ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true) . " ORDER BY update_date DESC";
$ilDB->setLimit(1);
$set = $ilDB->query($query);
$rec = $ilDB->fetchAssoc($set);
$id = (int) $rec["id"];
if ($a_only_today) {
$now = ilUtil::now();
if (substr($now, 0, 10) != substr($rec["update_date"], 0, 10)) {
$id = 0;
}
}
return $id;
}
示例9: updatePeerReviewComment
public function updatePeerReviewComment($a_peer_id, $a_comment)
{
global $ilDB, $ilUser;
$ilDB->manipulate("UPDATE exc_assignment_peer" . " SET tstamp = " . $ilDB->quote(ilUtil::now(), "timestamp") . ", pcomment = " . $ilDB->quote($a_comment, "text") . " WHERE giver_id = " . $ilDB->quote($ilUser->getId(), "integer") . " AND peer_id = " . $ilDB->quote($a_peer_id, "integer") . " AND ass_id = " . $ilDB->quote($this->getId(), "integer"));
}
示例10: _writeStatus
/**
* Write success status
*
* @param int $a_obj_id exercise id
* @param int $a_user_id member id
* @param int $status status: STATUS_NOT_GRADED|STATUS_PASSED|STATUS_FAILED
*
* @return int number of affected rows
*/
function _writeStatus($a_obj_id, $a_user_id, $a_status)
{
global $ilDB;
$ilDB->manipulate("DELETE FROM il_wiki_contributor WHERE " . " wiki_id = " . $ilDB->quote($a_obj_id, "integer") . " AND user_id = " . $ilDB->quote($a_user_id, "integer"));
$ilDB->manipulateF("INSERT INTO il_wiki_contributor (status, wiki_id, user_id, status_time) " . "VALUES (%s,%s,%s,%s)", array("integer", "integer", "integer", "timestamp"), array($a_status, $a_obj_id, $a_user_id, ilUtil::now()));
}
示例11: _setUserInactive
public static function _setUserInactive($a_usr_id)
{
global $ilDB;
$query = "UPDATE usr_data SET usr_data.active = 0, usr_data.inactivation_date = %s WHERE usr_data.usr_id = %s";
$affected = $ilDB->manipulateF($query, array('timestamp', 'integer'), array(ilUtil::now(), $a_usr_id));
if ($affected) {
return true;
} else {
return false;
}
}
示例12: object_data
require_once "./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php";
$orgu_type_id = ilDBUpdateNewObjectType::getObjectTypeId('orgu');
if ($orgu_type_id) {
$view_lp = ilDBUpdateNewObjectType::addCustomRBACOperation('view_learning_progress', 'View learning progress from users in this orgu.', 'object', 270);
$view_lp_rec = ilDBUpdateNewObjectType::addCustomRBACOperation('view_learning_progress_rec', 'View learning progress from users in this orgu and subsequent orgus.', 'object', 280);
if ($view_lp && $view_lp_rec) {
ilDBUpdateNewObjectType::addRBACOperation($orgu_type_id, $view_lp);
ilDBUpdateNewObjectType::addRBACOperation($orgu_type_id, $view_lp_rec);
}
}
?>
<#4035>
<?php
//ORGU TEMPLATES
$orgu_employee_contributor_tpl_id = $ilDB->nextId('object_data');
$ilDB->manipulateF("INSERT INTO object_data (obj_id, type, title, description," . " owner, create_date, last_update) VALUES (%s, %s, %s, %s, %s, %s, %s)", array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"), array($orgu_employee_contributor_tpl_id, "rolt", "il_orgu_superior", "OrgUnit Superior Role Template", -1, ilUtil::now(), ilUtil::now()));
$query = 'SELECT ops_id FROM rbac_operations WHERE operation = ' . $ilDB->quote('view_learning_progress', 'text');
$rset = $ilDB->query($query);
$row = $ilDB->fetchAssoc($rset);
$view_lp = $row['ops_id'];
if ($view_lp) {
// See LP
$ilDB->manipulateF("INSERT INTO rbac_templates (rol_id, type, ops_id, parent)" . " VALUES (%s, %s, %s, %s)", array("integer", "text", "integer", "integer"), array($orgu_employee_contributor_tpl_id, "orgu", $view_lp, 8));
//Show
$ilDB->manipulateF("INSERT INTO rbac_templates (rol_id, type, ops_id, parent)" . " VALUES (%s, %s, %s, %s)", array("integer", "text", "integer", "integer"), array($orgu_employee_contributor_tpl_id, "orgu", 2, 8));
//Read
$ilDB->manipulateF("INSERT INTO rbac_templates (rol_id, type, ops_id, parent)" . " VALUES (%s, %s, %s, %s)", array("integer", "text", "integer", "integer"), array($orgu_employee_contributor_tpl_id, "orgu", 3, 8));
//No idea
$ilDB->manipulateF("INSERT INTO rbac_fa (rol_id, parent, assign, protected)" . " VALUES (%s, %s, %s, %s)", array("integer", "integer", "text", "text"), array($orgu_employee_contributor_tpl_id, 8, "n", "n"));
}
?>
示例13: saveData
public function saveData($a_roles = array())
{
/**
* @var $ilDB ilDB
* @var $ilUser ilObjUser
*/
global $ilUser, $ilDB;
$nextId = $ilDB->nextId('frm_data');
$top_data = array('top_frm_fk' => $this->getId(), 'top_name' => $this->getTitle(), 'top_description' => $this->getDescription(), 'top_num_posts' => 0, 'top_num_threads' => 0, 'top_last_post' => NULL, 'top_mods' => !is_numeric($a_roles[0]) ? 0 : $a_roles[0], 'top_usr_id' => $ilUser->getId(), 'top_date' => ilUtil::now());
$statement = $ilDB->manipulateF('
INSERT INTO frm_data
(
top_pk,
top_frm_fk,
top_name,
top_description,
top_num_posts,
top_num_threads,
top_last_post,
top_mods,
top_date,
top_usr_id
)
VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)', array('integer', 'integer', 'text', 'text', 'integer', 'integer', 'text', 'integer', 'timestamp', 'integer'), array($nextId, $top_data['top_frm_fk'], $top_data['top_name'], $top_data['top_description'], $top_data['top_num_posts'], $top_data['top_num_threads'], $top_data['top_last_post'], $top_data['top_mods'], $top_data['top_date'], $top_data['top_usr_id']));
}
示例14: _isNodeVisible
/**
* Is node visible for the learner
*
* @param mixed $a_node node object/array
* @return boolean node visible true/false
*/
static function _isNodeVisible($a_node)
{
include_once "./Services/COPage/classes/class.ilPageObject.php";
if ($a_node["type"] != "pg") {
return true;
}
$lm_set = new ilSetting("lm");
$active = ilPageObject::_lookupActive($a_node["child"], "lm", $lm_set->get("time_scheduled_page_activation"));
if (!$active) {
$act_data = ilPageObject::_lookupActivationData((int) $a_node["child"], "lm");
if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
return true;
} else {
return false;
}
} else {
return true;
}
}
示例15: updateTextSubmission
/**
* Handle text assignment submissions
*
* @param int $a_exc_id
* @param int $a_ass_id
* @param int $a_user_id
* @param string $a_text
* @return int
*/
function updateTextSubmission($a_exc_id, $a_ass_id, $a_user_id, $a_text)
{
global $ilDB;
$files = ilExAssignment::getDeliveredFiles($a_exc_id, $a_ass_id, $a_user_id);
// no text = remove submission
if (!trim($a_text)) {
if ($files) {
$files = array_shift($files);
$id = $files["returned_id"];
if ($id) {
$this->deleteDeliveredFiles($a_exc_id, $a_ass_id, array($id), $a_user_id);
return;
}
}
}
if (!$files) {
return $this->addResourceObject("TEXT", $a_ass_id, $a_user_id, $a_text);
} else {
$files = array_shift($files);
$id = $files["returned_id"];
if ($id) {
$ilDB->manipulate("UPDATE exc_returned" . " SET atext = " . $ilDB->quote($a_text, "text") . ", ts = " . $ilDB->quote(ilUtil::now(), "timestamp") . " WHERE returned_id = " . $ilDB->quote($id, "integer"));
return $id;
}
}
}