/** * Import relevant properties from given test * * @param ilObjTest $a_test * @return object */ public static function createFromTest(ilObjTest $a_test, $a_user_id) { global $lng; $lng->loadLanguageModule("wsp"); $newObj = new self(); $newObj->setTitle($lng->txt("wsp_type_tstv") . " \"" . $a_test->getTitle() . "\""); $newObj->setDescription($a_test->getDescription()); $active_id = $a_test->getActiveIdOfUser($a_user_id); $pass = ilObjTest::_getResultPass($active_id); $date = $a_test->getPassFinishDate($active_id, $pass); $newObj->setProperty("issued_on", new ilDate($date, IL_CAL_UNIX)); // create certificate include_once "Services/Certificate/classes/class.ilCertificate.php"; include_once "Modules/Test/classes/class.ilTestCertificateAdapter.php"; $certificate = new ilCertificate(new ilTestCertificateAdapter($a_test)); $certificate = $certificate->outCertificate(array("active_id" => $active_id, "pass" => $pass), false); // save pdf file if ($certificate) { // we need the object id for storing the certificate file $newObj->create(); $path = self::initStorage($newObj->getId(), "certificate"); $file_name = "tst_" . $a_test->getId() . "_" . $a_user_id . "_" . $active_id . ".pdf"; if (file_put_contents($path . $file_name, $certificate)) { $newObj->setProperty("file", $file_name); $newObj->update(); return $newObj; } // file creation failed, so remove to object, too $newObj->delete(); } }
/** * Creates a zipper from an array, with a hole in the * 0-index position. * @param Array to zipper-ify. * @return Tuple of zipper and element of first position. */ public static function fromArray($array) { $z = new self(array(), array_reverse($array)); $t = $z->delete(); // delete the "dummy hole" return array($z, $t); }
/** * Import relevant properties from given exercise * * @param ilObjExercise $a_test * @return object */ public static function createFromExercise(ilObjExercise $a_exercise, $a_user_id) { global $lng; $lng->loadLanguageModule("exercise"); $newObj = new self(); $newObj->setTitle($a_exercise->getTitle()); $newObj->setDescription($a_exercise->getDescription()); include_once "Services/Tracking/classes/class.ilLPMarks.php"; $lp_marks = new ilLPMarks($a_exercise->getId(), $a_user_id); $newObj->setProperty("issued_on", new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME)); // create certificate include_once "Services/Certificate/classes/class.ilCertificate.php"; include_once "Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php"; $certificate = new ilCertificate(new ilExerciseCertificateAdapter($a_exercise)); $certificate = $certificate->outCertificate(array("user_id" => $a_user_id), false); // save pdf file if ($certificate) { // we need the object id for storing the certificate file $newObj->create(); $path = self::initStorage($newObj->getId(), "certificate"); $file_name = "exc_" . $a_exercise->getId() . "_" . $a_user_id . ".pdf"; if (file_put_contents($path . $file_name, $certificate)) { $newObj->setProperty("file", $file_name); $newObj->update(); return $newObj; } // file creation failed, so remove to object, too $newObj->delete(); } // remove if certificate works $newObj->create(); return $newObj; }
public static function mark(GWF_User $user, GWF_Links $link, $bool) { $userid = $user->getID(); $linkid = $link->getID(); $is_fav = self::table(__CLASS__)->getRow($userid, $linkid) !== false; if ($is_fav === $bool) { return true; } $row = new self(array('lf_uid' => $userid, 'lf_lid' => $linkid)); if ($bool) { if (!$row->replace()) { return false; } } else { if (!$row->delete()) { return false; } } if (false === $link->increase('link_favcount', $bool ? 1 : -1)) { return false; } if (false === $link->onCalcPopularity()) { return false; } return true; }
public static function setFavorite($userid, $siteid, $bool) { $entry = new self(array('sitefav_uid' => $userid, 'sitefav_sid' => $siteid)); if ($bool === true) { return $entry->replace(); } else { return $entry->delete(); } }
/** * 清除所有SessionFile * @return boolean */ static function clear() { $ret = TRUE; if ($sessions = $_SESSION['_Hiano_Session']['SessionFile']) { foreach ($sessions as $s_name => $s_value) { $sf = new self($s_name); if (!$sf->delete()) { $ret = false; } } } return $ret; }
static function cleanup($profile_list) { $subs = new self(); $subs->profile_tag_id = $profile_list->id; $subs->find(); while ($subs->fetch()) { $profile = Profile::getKV('id', $subs->profile_id); Event::handle('StartUnsubscribePeopletag', array($profile_list, $profile)); // Delete anyway $subs->delete(); Event::handle('StartUnsubscribePeopletag', array($profile_list, $profile)); } }
static function uninstall() { global $DB; //uninstall container table and class $obj = new self(); $containers = $obj->find(); foreach ($containers as $containers_id => $container) { $obj->delete(array('id' => $containers_id)); } //drop global container table $obj = new self(); $DB->query("DROP TABLE IF EXISTS `" . $obj->getTable() . "`"); //delete display preferences for this item $DB->query("DELETE FROM glpi_displaypreferences WHERE `itemtype` = '" . __CLASS__ . "'"); return true; }
/** * Update IPNetwork's dependency * * @param $network IPNetwork object **/ static function linkIPAddressFromIPNetwork(IPNetwork $network) { global $DB; $linkObject = new self(); $linkTable = $linkObject->getTable(); $ipnetworks_id = $network->getID(); // First, remove all links of the current Network $query = "SELECT `id`\n FROM `{$linkTable}`\n WHERE `ipnetworks_id` = '{$ipnetworks_id}'"; foreach ($DB->request($query) as $link) { $linkObject->delete(array('id' => $link['id'])); } // Then, look each IP address contained inside current Network $query = "SELECT '" . $ipnetworks_id . "' AS ipnetworks_id,\n `id` AS ipaddresses_id\n FROM `glpi_ipaddresses`\n WHERE " . $network->getWHEREForMatchingElement('glpi_ipaddresses', 'binary', 'version') . "\n GROUP BY `id`"; foreach ($DB->request($query) as $link) { $linkObject->add($link); } }
public static function retrieve($endpoint, $params = null, $method = 'get') { $fs = new self(); $method = strtolower($method); switch ($method) { case 'get': return $fs->get($endpoint, $params); break; case 'post': return $fs->post($endpoint, $params); break; case 'delete': return $fs->delete($endpoint, $params); break; default: throw new ddFoursquareBadRequestException('The given method is invalid.'); } }
public static function refreshOnline($IDUser = null, $Location = null) { if (!isset($IDUser)) { $IDUser = Zend_Auth::getInstance()->getIdentity()->IDUser; } $TheOnline = new self(); $Data = array('Date' => new Zend_Db_Expr('NOW()')); if (isset($Location)) { $Data['IDLocation'] = $Location; } $Online = $TheOnline->fetchAll("IDUser = '******'"); if ($Online->count() == 1) { $TheOnline->update($Data, "IDUser = '******'"); } else { if ($Online->count() > 1) { $TheOnline->delete("IDUser = '******'"); } $Data['IDUser'] = $IDUser; $TheOnline->insert($Data); } }
/** * Import relevant properties from given learning module * * @param ilObjSAHSLearningModule $a_lm * @return object */ public static function createFromSCORMLM(ilObjSAHSLearningModule $a_lm, $a_user_id) { global $lng; $lng->loadLanguageModule("sahs"); $newObj = new self(); $newObj->setTitle($a_lm->getTitle()); $newObj->setDescription($a_lm->getDescription()); include_once "Services/Tracking/classes/class.ilLPMarks.php"; $lp_marks = new ilLPMarks($a_lm->getId(), $a_user_id); $newObj->setProperty("issued_on", new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME)); // create certificate if (!stristr(get_class($a_lm), "2004")) { $last_access = ilObjSCORMLearningModule::_lookupLastAccess($a_lm->getId(), $a_user_id); } else { $last_access = ilObjSCORM2004LearningModule::_lookupLastAccess($a_lm->getId(), $a_user_id); } $params = array("user_data" => ilObjUser::_lookupFields($a_user_id), "last_access" => $last_access); include_once "Services/Certificate/classes/class.ilCertificate.php"; include_once "Modules/ScormAicc/classes/class.ilSCORMCertificateAdapter.php"; $certificate = new ilCertificate(new ilSCORMCertificateAdapter($a_lm)); $certificate = $certificate->outCertificate($params, false); // save pdf file if ($certificate) { // we need the object id for storing the certificate file $newObj->create(); $path = self::initStorage($newObj->getId(), "certificate"); $file_name = "sahs_" . $a_lm->getId() . "_" . $a_user_id . ".pdf"; if (file_put_contents($path . $file_name, $certificate)) { $newObj->setProperty("file", $file_name); $newObj->update(); return $newObj; } // file creation failed, so remove to object, too $newObj->delete(); } }
/** * Delete all portfolio data for user * * @param int $a_user_id */ public static function deleteUserPortfolios($a_user_id) { $all = self::getPortfoliosOfUser($a_user_id); if ($all) { include_once "Modules/Portfolio/classes/class.ilPortfolioAccessHandler.php"; $access_handler = new ilPortfolioAccessHandler(); foreach ($all as $item) { $access_handler->removePermission($item["id"]); $portfolio = new self($item["id"], false); $portfolio->delete(); } } }
/** * Change a particular configuration value * * @param string $feature Feature * @param mixed $value Value * @param CMbObject $object Host object * * @return null|string Store-like message */ static function setConfig($feature, $value, CMbObject $object = null) { $where = array("feature" => "= '{$feature}'"); if ($object) { $where["object_class"] = "= '{$object->_class}'"; $where["object_id"] = "= '{$object->_id}'"; } else { $where["object_class"] = "IS NULL"; $where["object_id"] = "IS NULL"; } $_config = new self(); $_config->loadObject($where); $inherit = $value === self::INHERIT; if ($_config->_id && $inherit) { return $_config->delete(); } elseif (!$inherit) { if ($object) { $_config->setObject($object); } else { $_config->object_id = null; $_config->object_class = null; } $_config->feature = $feature; $_config->value = $value; return $_config->store(); } return null; }
/** * Delete config entries * * @since version 0.85 * * @param $context string context to get values (default for glpi is core) * @param $values array of config names to delete * * @return array of config values **/ static function deleteConfigurationValues($context, array $values = array()) { $config = new self(); foreach ($values as $value) { if ($config->getFromDBByQuery("WHERE `context` = '{$context}'\n AND `name` = '{$value}'")) { $config->delete(array('id' => $config->getID())); } } }
static function cleanProfiles(Profile $prof) { $plugprof = new self(); $plugprof->delete(array('id' => $prof->getField("id"))); }
static function methodDeleteAppliance($params, $protocol) { global $DB; if (isset($params['help'])) { return array('help' => 'bool,optional', 'force' => 'boolean,optional', 'id' => 'string'); } if (!Session::getLoginUserID()) { return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED); } if (!isset($params['id'])) { return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER); } $force = 0; if (isset($params['force'])) { $force = 1; } $id = $params['id']; $appliance = new self(); if (!$appliance->can($id, 'd')) { return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED); } if (!$appliance->delete(array("id" => $id), $force)) { return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_FAILED); } return array("id" => $id); }
/** * Delete all strings. */ public function deleteAll() { // Other languages if (isset($this->_languages)) { foreach ($this->_languages as $item) { $lang = new self(); $lang->setItem((array) $item); $lang->delete(); } return true; } }
/** * Do a specific SLAlevel for a ticket * * @param $data array data of an entry of slalevels_tickets * * @return nothing **/ static function doLevelForTicket(array $data) { $ticket = new Ticket(); $slalevelticket = new self(); // existing ticket and not deleted if ($ticket->getFromDB($data['tickets_id']) && !$ticket->isDeleted()) { // search all actors of a ticket foreach ($ticket->getUsers(CommonITILActor::REQUESTER) as $user) { $ticket->fields['_users_id_requester'][] = $user['users_id']; } foreach ($ticket->getUsers(CommonITILActor::ASSIGN) as $user) { $ticket->fields['_users_id_assign'][] = $user['users_id']; } foreach ($ticket->getUsers(CommonITILActor::OBSERVER) as $user) { $ticket->fields['_users_id_observer'][] = $user['users_id']; } foreach ($ticket->getGroups(CommonITILActor::REQUESTER) as $group) { $ticket->fields['_groups_id_requester'][] = $group['groups_id']; } foreach ($ticket->getGroups(CommonITILActor::ASSIGN) as $group) { $ticket->fields['_groups_id_assign'][] = $group['groups_id']; } foreach ($ticket->getGroups(CommonITILActor::OBSERVER) as $groups) { $ticket->fields['_groups_id_observer'][] = $group['groups_id']; } foreach ($ticket->getSuppliers(CommonITILActor::ASSIGN) as $supplier) { $ticket->fields['_suppliers_id_assign'][] = $supplier['suppliers_id']; } $slalevel = new SlaLevel(); $sla = new SLA(); // Check if sla datas are OK if ($ticket->fields['slas_id'] > 0 && $ticket->fields['slalevels_id'] == $data['slalevels_id']) { if ($ticket->fields['status'] == CommonITILObject::CLOSED) { // Drop line when status is closed $slalevelticket->delete(array('id' => $data['id'])); } else { if ($ticket->fields['status'] != CommonITILObject::SOLVED) { // If status = solved : keep the line in case of solution not validated $input['id'] = $ticket->getID(); $input['_auto_update'] = true; if ($slalevel->getRuleWithCriteriasAndActions($data['slalevels_id'], 1, 1) && $sla->getFromDB($ticket->fields['slas_id'])) { $doit = true; if (count($slalevel->criterias)) { $doit = $slalevel->checkCriterias($ticket->fields); } // Process rules if ($doit) { $input = $slalevel->executeActions($input, array()); } } // Put next level in todo list $next = $slalevel->getNextSlaLevel($ticket->fields['slas_id'], $ticket->fields['slalevels_id']); $input['slalevels_id'] = $next; $ticket->update($input); $sla->addLevelToDo($ticket); // Action done : drop the line $slalevelticket->delete(array('id' => $data['id'])); } } } else { // Drop line $slalevelticket->delete(array('id' => $data['id'])); } } else { // Drop line $slalevelticket->delete(array('id' => $data['id'])); } }
/** * @param $users_id **/ static function manageDeletedUserInLdap($users_id) { global $CFG_GLPI; //The only case where users_id can be null if when a user has been imported into GLPi //it's dn still exists, but doesn't match the connection filter anymore //In this case, do not try to process the user if (!$users_id) { return true; } //User is present in DB but not in the directory : it's been deleted in LDAP $tmp['id'] = $users_id; $tmp['is_deleted_ldap'] = 1; $myuser = new self(); $myuser->getFromDB($users_id); //User is already considered as delete from ldap if ($myuser->fields['is_deleted_ldap'] == 1) { return; } switch ($CFG_GLPI['user_deleted_ldap']) { //DO nothing default: case 0: $myuser->update($tmp); break; //Put user in dustbin //Put user in dustbin case 1: $myuser->delete($tmp); break; //Delete all user dynamic habilitations and groups //Delete all user dynamic habilitations and groups case 2: Profile_User::deleteRights($users_id, true); Group_User::deleteGroups($users_id, true); $myuser->update($tmp); break; //Deactivate the user //Deactivate the user case 3: $tmp['is_active'] = 0; $myuser->update($tmp); break; //Deactivate the user+ Delete all user dynamic habilitations and groups //Deactivate the user+ Delete all user dynamic habilitations and groups case 4: $tmp['is_active'] = 0; $myuser->update($tmp); Profile_User::deleteRights($users_id, true); Group_User::deleteGroups($users_id, true); break; } /* $changes[0] = '0'; $changes[1] = ''; $changes[2] = __('Deleted user in LDAP directory'); Log::history($users_id, 'User', $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);*/ }
/** * (non-PHPdoc) * @see Site/lib/models/SPDBObject#delete() * @param bool $childs - update child entries parent */ public function delete($childs = true) { parent::delete(); SPFactory::cache()->cleanSection(); SPFactory::cache()->deleteObj('category', $this->id); try { /* get all child cats and delete these too */ $childs = $this->getChilds('category', true); if (count($childs)) { foreach ($childs as $child) { $cat = new self(); $cat->init($child); $cat->delete(false); } } $childs[$this->id] = $this->id; SPFactory::db()->delete('spdb_category', array('id' => $this->id)); if ($childs) { SPFactory::db()->update('spdb_object', array('parent' => Sobi::Section()), array('parent' => $childs)); } } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('CANNOT_DELETE_CATEGORY_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } }
/** * Generate completename associated with a tree dropdown * * @param $input array of user values * @param $add boolean true if translation is added, false if update (tgrue by default) * * @return nothing **/ function generateCompletename($input, $add = true) { global $DB; // Force completename translated : used for the first translation $_SESSION['glpi_dropdowntranslations'][$input['itemtype']]['completename'] = 'completename'; //If there's already a completename for this language, get it's ID, otherwise 0 $completenames_id = self::getTranslationID($input['items_id'], $input['itemtype'], 'completename', $input['language']); $item = new $input['itemtype'](); //Completename is used only for tree dropdowns ! if ($item instanceof CommonTreeDropdown && isset($input['language'])) { $item->getFromDB($input['items_id']); $foreignKey = $item->getForeignKeyField(); //Regenerate completename : look for item's ancestors $completename = ""; //Get ancestors as an array if ($item->fields[$foreignKey] != 0) { $completename = self::getTranslatedValue($item->fields[$foreignKey], $input['itemtype'], 'completename', $input['language']); } if ($completename != '') { $completename .= " > "; } $completename .= self::getTranslatedValue($item->getID(), $input['itemtype'], 'name', $input['language']); //Add or update completename for this language $translation = new self(); $tmp = array(); $tmp['items_id'] = $input['items_id']; $tmp['itemtype'] = $input['itemtype']; $tmp['field'] = 'completename'; $tmp['value'] = addslashes($completename); $tmp['language'] = $input['language']; $tmp['_no_completename'] = true; if ($completenames_id) { $tmp['id'] = $completenames_id; if ($completename === $item->fields['completename']) { $translation->delete(array('id' => $completenames_id)); } else { $translation->update($tmp); } } else { if ($completename != $item->fields['completename']) { $translation->add($tmp); } } $query = "SELECT `id`\n FROM `" . $item->getTable() . "`\n WHERE `{$foreignKey}` = '" . $item->getID() . "'"; foreach ($DB->request($query) as $tmp) { $input2 = $input; $input2['items_id'] = $tmp['id']; $this->generateCompletename($input2, $add); } } }
public static function makeList($ALLOW_EDIT) { global $lng, $coach, $settings; HTMLOUT::frame_begin(is_object($coach) ? $coach->settings['theme'] : $settings['stylesheet']); # Make page frame, banner and menu. /* A new entry was sent. Add it to system */ if (isset($_POST['tid']) && $ALLOW_EDIT) { if (get_magic_quotes_gpc()) { $_POST['title'] = stripslashes($_POST['title']); $_POST['about'] = stripslashes($_POST['about']); } switch ($_GET['action']) { case 'edit': $e = new self($_GET['ft_id']); status($e->edit($_POST['title'], $_POST['about'])); break; case 'new': status(self::create($_POST['tid'], $_POST['title'], $_POST['about'])); break; } } title($lng->getTrn('name', __CLASS__)); /* Was a request for a new entry made? */ if (isset($_GET['action']) && $ALLOW_EDIT) { // Default schema values. These are empty unless "edit" is chosen. $tid = false; $title = ''; $about = ''; switch ($_GET['action']) { case 'delete': if (isset($_GET['ft_id']) && is_numeric($_GET['ft_id'])) { $e = new self($_GET['ft_id']); status($e->delete()); unset($e); } else { fatal('Sorry. You did not specify which FT-id you wish to delete.'); } break; case 'edit': if (isset($_GET['ft_id']) && is_numeric($_GET['ft_id'])) { $e = new self($_GET['ft_id']); $tid = $e->tid; $title = $e->title; $about = $e->about; $_POST['lid'] = get_alt_col('mv_teams', 'f_tid', $tid, 'f_lid'); } else { fatal('Sorry. You did not specify which FT-id you wish to edit.'); } // Fall-through to "new" !!! // Fall-through to "new" !!! case 'new': echo "<a href='handler.php?type=famousteams'><-- " . $lng->getTrn('common/back') . "</a><br><br>"; $_DISABLED = !isset($_POST['lid']) ? 'DISABLED' : ''; $node_id = isset($_POST['lid']) ? $_POST['lid'] : null; ?> <form name="STS" method="POST" enctype="multipart/form-data"> <b><?php echo $lng->getTrn('common/league'); ?> </b><br> <?php echo HTMLOUT::nodeList(T_NODE_LEAGUE, 'lid', array(), array(), array('sel_id' => $node_id)); ?> <input type='submit' value='<?php echo $lng->getTrn('common/select'); ?> '> </form> <br> <form method="POST"> <b><?php echo $lng->getTrn('team', __CLASS__) . '</b>'; ?> <br> <?php $query = "SELECT team_id, name FROM teams WHERE f_lid = {$node_id} ORDER by name ASC"; $result = mysql_query($query); if ($result && mysql_num_rows($result) == 0) { $_DISABLED = 'DISABLED'; } ?> <select name="tid" id="teams" <?php echo $_DISABLED; ?> > <?php while ($row = mysql_fetch_assoc($result)) { echo "<option value='{$row['team_id']}' " . ($tid == $row['team_id'] ? 'SELECTED' : '') . ">{$row['name']}</option>\n"; } ?> </select> <br><br> <b><?php echo $lng->getTrn('g_title', __CLASS__) . '</b> — ' . $lng->getTrn('title', __CLASS__); ?> <br> <input type="text" name="title" size="60" maxlength="100" value="<?php echo $title; ?> " <?php echo $_DISABLED; ?> > <br><br> <b><?php echo $lng->getTrn('g_about', __CLASS__) . '</b> — ' . $lng->getTrn('about', __CLASS__); ?> <br> <textarea name="about" rows="15" cols="100" <?php echo $_DISABLED; ?> ><?php echo $about; ?> </textarea> <br><br> <input type="submit" value="<?php echo $lng->getTrn('submit', __CLASS__); ?> " name="Submit" <?php echo $_DISABLED; ?> > </form> <?php return; break; } } /* Print the hall of fame */ echo $lng->getTrn('desc', __CLASS__) . "<br><br>\n"; list($sel_node, $sel_node_id) = HTMLOUT::nodeSelector(array()); if ($ALLOW_EDIT) { echo "<br><a href='handler.php?type=famousteams&action=new'>" . $lng->getTrn('new', __CLASS__) . "</a><br>\n"; } self::printList($sel_node, $sel_node_id, $ALLOW_EDIT); HTMLOUT::frame_end(); }
protected static function moveStatic($name1, $name2) { $self = new self(); if ($self->exists($name)) { $content = $self->get($name1); $self->put($name2, $content); $self->delete($name1); } else { throw new \InvalidArgumentException("There is no file calls {$name}"); } }
public static function deleteFile($path) { $f = new self($path); return $f->delete(); }
/** * @param $users_id **/ static function manageDeletedUserInLdap($users_id) { global $CFG_GLPI; //User is present in DB but not in the directory : it's been deleted in LDAP $tmp['id'] = $users_id; $tmp['is_deleted_ldap'] = 1; $myuser = new self(); $myuser->getFromDB($users_id); //User is already considered as delete from ldap if ($myuser->fields['is_deleted_ldap'] == 1) { return; } switch ($CFG_GLPI['user_deleted_ldap']) { //DO nothing default: case 0: $myuser->update($tmp); break; //Put user in dustbin //Put user in dustbin case 1: $myuser->delete($tmp); break; //Delete all user dynamic habilitations and groups //Delete all user dynamic habilitations and groups case 2: Profile_User::deleteRights($users_id, true); Group_User::deleteGroups($users_id, true); $myuser->update($tmp); break; //Deactivate the user //Deactivate the user case 3: $tmp['is_active'] = 0; $myuser->update($tmp); break; } /* $changes[0] = '0'; $changes[1] = ''; $changes[2] = __('Deleted user in LDAP directory'); Log::history($users_id, 'User', $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);*/ }
/** * Manage recall set * * @param $data array of data to manage **/ static function manageDatas(array $data) { // Check data informations if (!isset($data['itemtype']) || !isset($data['items_id']) || !isset($data['users_id']) || !isset($data['before_time']) || !isset($data['field'])) { return false; } $pr = new self(); // Datas OK : check if recall already exists if ($pr->getFromDBForItemAndUser($data['itemtype'], $data['items_id'], $data['users_id'])) { if ($data['before_time'] != $pr->fields['before_time']) { // Recall exists and is different : update datas and clean alert if ($pr->can($pr->fields['id'], 'w')) { if ($item = getItemForItemtype($data['itemtype'])) { if ($item->getFromDB($data['items_id']) && isset($item->fields[$data['field']]) && !empty($item->fields[$data['field']])) { $when = date("Y-m-d H:i:s", strtotime($item->fields[$data['field']]) - $data['before_time']); if ($data['before_time'] >= 0) { $pr->update(array('id' => $pr->fields['id'], 'before_time' => $data['before_time'], 'when' => $when)); } else { $pr->delete(array('id' => $pr->fields['id'])); } } } } } } else { // Recall does not exists : create it if ($pr->can(-1, 'w', $data)) { if ($item = getItemForItemtype($data['itemtype'])) { $item->getFromDB($data['items_id']); if ($item->getFromDB($data['items_id']) && isset($item->fields[$data['field']]) && !empty($item->fields[$data['field']])) { $data['when'] = date("Y-m-d H:i:s", strtotime($item->fields[$data['field']]) - $data['before_time']); if ($data['before_time'] >= 0) { $pr->add($data); } } } } } }
/** * 删除日志 */ public static final function remove() { // 获取数据 $book = new self(); $book->book_id = isset($_GET['book_id']) ? $_GET['book_id'] : null; if (!is_numeric($book->book_id) || !$book->select()) { $error = '该日志不存在'; front::view2('error.tpl', compact('error')); return; } // 删除数据 $book->delete(); header('Location: ?' . $_GET['query']); }
function post_purgeItem() { global $DB; parent::post_purgeItem(); $ticket = new Ticket(); $itemtype_id = $ticket->getSearchOptionIDByField('field', 'itemtype', 'glpi_tickets'); $items_id_id = $ticket->getSearchOptionIDByField('field', 'items_id', 'glpi_tickets'); // Try to delete itemtype -> delete items_id if ($this->fields['num'] == $itemtype_id) { $query = "SELECT `id`\n FROM `" . $this->getTable() . "`\n WHERE `" . static::$items_id . "` = '" . $this->fields['tickettemplates_id'] . "'\n AND `num` = '{$items_id_id}'"; if ($result = $DB->query($query)) { if ($DB->numrows($result)) { $a = new self(); $a->delete(array('id' => $DB->result($result, 0, 0))); } } } }
/** * 删除用户 */ public static final function remove() { // 获取数据 $user = new self(); $user->user_id = isset($_GET['user_id']) ? $_GET['user_id'] : null; if (!is_numeric($user->user_id) || !$user->select()) { $error = '该用户不存在'; self::view(__CLASS__ . '/error.tpl', compact('error')); return; } // 删除数据 $user->delete(); header('Location: ?' . $_GET['query']); }