/** * Register login */ public static function registerLogin() { TTransaction::open('log'); $object = new self(); $object->login = TSession::getValue('login'); $object->sessionid = session_id(); $object->login_time = date("Y-m-d H:i:s"); $object->store(); TTransaction::close(); }
/** * Get a instance for a name * * @param string $name * @return self */ static function get($name) { $object = RDR_Category::getByCondition(db()->quote("user") . " = {1} AND name = {0}", array($name, user())); if ($object) { return reset($object); } $object = new self(db()); $object->name = $name; $object->user = user(); $object->store(); return $object; }
/** * Registers import handler that is currently processed * @param string $handlerName */ public static function setCurrentHandler($handlerName) { // First check if a current handler is already registered $handlerToken = parent::fetchObject(self::definition(), null, array('name' => self::CURRENT_HANDLER_FIELD_NAME)); if ($handlerToken instanceof SQLIImportToken) { $handlerToken->setAttribute('value', $handlerName); } else { $row = array('name' => self::CURRENT_HANDLER_FIELD_NAME, 'value' => $handlerName); $handlerToken = new self($row); $handlerToken->store(); } }
/** * Register a change log */ public static function register($activeRecord, $lastState, $currentState) { $table = $activeRecord->getEntity(); $pk = $activeRecord->getPrimaryKey(); TTransaction::open('log'); foreach ($lastState as $key => $value) { if (!isset($currentState[$key])) { // deleted $log = new self(); $log->tablename = $table; $log->logdate = date('Y-m-d H:i:s'); $log->login = TSession::getValue('login'); $log->primarykey = $pk; $log->pkvalue = $activeRecord->{$pk}; $log->operation = 'deleted'; $log->columnname = $key; $log->oldvalue = $value; $log->newvalue = ''; $log->store(); } } foreach ($currentState as $key => $value) { if (isset($lastState[$key]) and $value != $lastState[$key]) { // changed $log = new self(); $log->tablename = $table; $log->logdate = date('Y-m-d H:i:s'); $log->login = TSession::getValue('login'); $log->primarykey = $pk; $log->pkvalue = $activeRecord->{$pk}; $log->operation = 'changed'; $log->columnname = $key; $log->oldvalue = $lastState[$key]; $log->newvalue = $value; $log->store(); } if (!isset($lastState[$key]) and !empty($value)) { // created $log = new self(); $log->tablename = $table; $log->logdate = date('Y-m-d H:i:s'); $log->login = TSession::getValue('login'); $log->primarykey = $pk; $log->pkvalue = $activeRecord->{$pk}; $log->operation = 'created'; $log->columnname = $key; $log->oldvalue = ''; $log->newvalue = $value; $log->store(); } } TTransaction::close(); }
/** * Create a log entry * * @param int $type * @param array $params * @return self */ static function log($type, $params = null) { $object = new self(db()); $object->type = $type; if (is_array($params)) { foreach ($params as $key => $value) { $object->{$key} = $value; } } $object->store(); self::$lastEvent = $object; return $object; }
public static function geraParcelas($id_cliente, $delay, $valor, $parcelas) { $date = new DateTime(date('Y-m-d')); $date->add(new DateInterval('P' . $delay . 'D')); for ($n = 1; $n <= $parcelas; $n++) { $conta = new self(); $conta->id_cliente = $id_cliente; $conta->dt_emissao = date('Y-m-d'); $conta->dt_vencimento = $date->format('Y-m-d'); $conta->valor = $valor / $parcelas; $conta->paga = 'N'; $conta->store(); $date->add(new DateInterval('P1M')); } }
/** * Writes an message in the global logger * @param $message Message to be written */ public function write($message) { $dbname = TTransaction::getDatabase(); // avoid log of log if ($dbname !== 'log' and in_array(substr($message, 0, 6), array('INSERT', 'UPDATE', 'DELETE'))) { $time = date("Y-m-d H:i:s"); TTransaction::open('log'); $object = new self(); $object->logdate = $time; $object->login = TSession::getValue('login'); $object->database_name = $dbname; $object->sql_command = $message; $object->statement_type = strtoupper(substr($message, 0, 6)); $object->store(); TTransaction::close(); } }
/** * Get settings entry, create if not exist * * @param mixed $key * @return self */ static function get($key) { if (isset(self::$_cache[$key])) { return self::$_cache[$key]; } $object = self::getByCondition(db()->quote("key") . " = {0}", array($key)); if ($object) { self::$_cache[$key] = reset($object); return self::$_cache[$key]; } else { $object = new self(db()); $object->key = $key; $object->value = ""; $object->store(); self::$_cache[$key] = $object; return $object; } }
/** * @see parent::store() */ function store() { if ($msg = parent::store()) { return $msg; } if ($this->_duplicate) { $duplicate = new self(); foreach ($this->getProperties() as $name => $value) { if ($name[0] !== "_" && $name != $this->_spec->key) { $duplicate->{$name} = $value; } } $duplicate->nom .= " (Copy)"; if ($duplicate->libelle) { $duplicate->libelle .= " (Copy)"; } $duplicate->store(); } $this->_duplicate = null; }
/** * Добавление копии удалённого объекта в корзину * * @global User $my - объект текущего пользователя * @param stdClass $obj - удаляемый объект * * @return boolean результат сохранения копии удаляемого объекта в корзину */ public static function add($obj_original) { $obj = clone $obj_original; // ключевое индексное поле объекта $_tbl_key = $obj->_tbl_key; // если у удаляемого объекта отсутствует ключ - то объет не определён if (!$obj_original->{$_tbl_key}) { return false; } // удаляем объект базы данных unset($obj->_db, $obj->_error); // собираем данные для сохранения резервной копии $trash = new self(); $trash->obj_id = $obj->{$_tbl_key}; $trash->obj_table = $obj->_tbl; $trash->title = isset($obj->title) ? $obj->title : $obj->{$_tbl_key}; $trash->data = json_encode($obj); $trash->user_id = modelUsers::instance()->id; $trash->deleted_at = JCURRENT_SERVER_TIME; return (bool) $trash->store(); }
/** * @param int $quizId * @param string $clusterIdentifier * @param int $applicationId * @param int $points * @param int $correctAnswer */ static function add( $quizId, $clusterIdentifier, $applicationId, $points, $correctAnswer ) { $quizMeta = self::fetchObject( self::definition(), null, array( 'quiz_id' => $quizId, 'cluster_identifier' => $clusterIdentifier ) ); if( !$quizMeta ) { $quizMeta = new self(); $quizMeta->setAttribute( 'quiz_id', $quizId ); } $quizMeta->setAttribute( 'cluster_identifier', $clusterIdentifier ); $quizMeta->setAttribute( 'application_id', $applicationId ); $quizMeta->setAttribute( 'points', $points ); $quizMeta->setAttribute( 'correct_answer', $correctAnswer ); $quizMeta->store(); }
/** * @see parent::updatePlainFields() */ function updatePlainFields() { parent::updatePlainFields(); if ($this->_type) { list($this->object_class, $this->object_id) = explode("-", $this->_type); $this->_type = null; } if ($this->_before && $this->_before != $this->_id) { $next_object = new self(); $next_object->load($this->_before); if ($next_object->_id) { $query = ''; $table = $this->_spec->table; if ($this->position) { $query = "AND `{$table}`.`position` BETWEEN {$next_object->position} AND {$this->position}"; } else { if ($next_object->position) { $query = "AND `{$table}`.`position` >= {$next_object->position}"; } } $where = array("`{$table}`.`position` IS NOT NULL {$query}", "`{$table}`.`object_class` = '{$this->object_class}'", "`{$table}`.`object_id` = '{$this->object_id}'"); $this->position = $next_object->position; /** @var self[] $next_objects */ $next_objects = $this->loadList($where); foreach ($next_objects as &$object) { $object->position++; $object->store(); } if (count($next_objects) == 0) { $next_object->position = 2; $next_object->store(); $this->position = 1; } } $this->_before = null; } else { if (!$this->_id && !$this->position) { $existing = $this->loadList(null, "position"); if ($location = end($existing)) { $this->position = $location->position + 1; } else { $this->position = 1; } } } }
/** * @param string $content * @return array */ static function add( $content ) { $currentMMUser = MMUsers::getCurrentUserObject(); if( !$currentMMUser ) return false; $prcuh = self::fetchObject( self::definition(), null, array( 'md5_uuid' => md5( $currentMMUser->attribute( 'uuid' ) ) ) ); if( !$prcuh ) { $prcuh = new self(); $prcuh->setAttribute( 'md5_uuid', md5( $currentMMUser->attribute( 'uuid' ) ) ); } if( $prcuh && $content != 'undefined' ) { $prcuh->setAttribute( 'content', $content ); } $prcuh->store(); return array( 'token' => $prcuh->attribute( 'md5_uuid' ) ); }
/** * Update all quotas of a certain class ID to reflect a change in class defaults * * NOTE: we're not using this anymore. Now, class changes are reflected for * individual users on login. * * @param integer $id * @return boolean */ public function updateUsersByClassId($id) { $class = new QuotasClasses($this->_db); $class->load($id); if (!$class->id) { return false; } $records = self::getRecords(array('class_id' => $class->id)); if ($records && count($records) > 0) { foreach ($records as $r) { $quota = new self($this->_db); $quota->load($r->id); $quota->set('hard_files', $class->hard_files); $quota->set('soft_files', $class->soft_files); $quota->set('hard_blocks', $class->hard_blocks); $quota->set('soft_blocks', $class->soft_blocks); $quota->store(); } } return true; }
/** * Clone core folders and queries and assign * them to a given user ID * * @param integer $user_id User ID * @return array */ public function cloneCore($user_id = 0) { // Get all the default folders $folders = $this->find('list', array('user_id' => 0, 'sort' => 'ordering', 'sort_Dir' => 'asc', 'iscore' => 1)); $sq = new Query($this->_db); if (count($folders) <= 0) { $defaults = array(1 => array('Common', 'Mine', 'Custom'), 2 => array('Common', 'Mine')); foreach ($defaults as $iscore => $fldrs) { $i = 1; foreach ($fldrs as $fldr) { $f = new self($this->_db); $f->iscore = $iscore; $f->title = $fldr; $f->check(); $f->ordering = $i; $f->user_id = 0; $f->store(); switch ($f->alias) { case 'common': $j = $iscore == 1 ? $sq->populateDefaults('common', $f->id) : $sq->populateDefaults('commonnotacl', $f->id); break; case 'mine': $sq->populateDefaults('mine', $f->id); break; default: // Nothing for custom folder break; } $i++; if ($iscore == 1) { $folders[] = $f; } } } } $user_id = $user_id ?: User::get('id'); $fid = 0; // Loop through each folder foreach ($folders as $k => $folder) { // Copy the folder for the user $stqf = new self($this->_db); $stqf->bind($folder); $stqf->created_by = $user_id; $stqf->created = Date::toSql(); $stqf->id = null; $stqf->user_id = $user_id; $stqf->iscore = 0; $stqf->store(); $queries = $sq->find('list', array('folder_id' => $folder->id)); // Copy all the queries from the folder to the user foreach ($queries as $query) { $stq = new Query($this->_db); $stq->bind($query); $stq->created_by = $user_id; $stq->created = Date::toSql(); $stq->id = null; $stq->user_id = $user_id; $stq->folder_id = $stqf->get('id'); $stq->iscore = 0; $stq->store(); } // If the folder is "custom", get its ID if ($folder->alias == 'custom') { $fid = $stqf->get('id'); } $folders[$k] = $stqf; } if ($fid) { $this->_db->setQuery("UPDATE `#__support_queries` SET `folder_id`=" . $this->_db->quote($fid) . " WHERE `user_id`=" . $this->_db->quote($user_id) . " AND `iscore`=0 AND `folder_id`=0"); $this->_db->query(); } return $folders; }
/** * Adds a version to the publishing queue * @param eZContentObjectVersion $version * @return ezpContentPublishingProcess */ public static function queue(eZContentObjectVersion $version) { $row = array('ezcontentobject_version_id' => $version->attribute('id'), 'created' => time(), 'status' => self::STATUS_PENDING); $processObject = new self($row); $processObject->store(); return $processObject; }
/** * Создание токена для пользователя */ public function generate_token($user_id) { $token_string = md5(joosRandomizer::hash(32) . $user_id . JCURRENT_SERVER_TIME); //создаем запись в таблице $obj = new self(); $obj->user_id = (int) $user_id; $obj->token = $token_string; //вещи связанные только с текущим браузером пользователя, на случай кражи токена $obj->user_related = md5($this->get_related_string()); $obj->store(); //и ставим куку на заданный промежуток времени joosCookie::set(self::$_token_name, $token_string, array('expires' => time() + self::$_session_ttl)); return true; }
/** * Register stamp * * @param integer $projectid Project ID * @param string $reference Reference string to object (JSON) * @return mixed False if error, Object on success */ public function registerStamp($projectid = 0, $reference = '', $type = 'files', $listed = 0, $expires = NULL) { if (!$projectid || !$reference) { return false; } $now = Date::toSql(); $obj = new self($this->_db); $obj->checkStamp($projectid, $reference, $type); // Load record if ($obj->id) { if ($obj->expires && $obj->expires != '0000-00-00 00:00:00' && $obj->expires < $now) { // Expired $obj->delete(); return $this->registerStamp($projectid, $reference, $type, $listed, $expires); } else { if ($listed === NULL && $expires === NULL) { return $obj->stamp; } // These values may be updated $obj->listed = $listed === NULL ? $obj->listed : $listed; $obj->expires = $expires === NULL ? $obj->expires : $expires; $obj->store(); return $obj->stamp; } } // Make new entry $created = Date::toSql(); $created_by = User::get('id'); // Generate stamp require_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'helpers' . DS . 'html.php'; $stamp = \Components\Projects\Helpers\Html::generateCode(20, 20, 0, 1, 1); $query = "INSERT INTO {$this->_tbl} (stamp, projectid, listed, type, reference, expires, created, created_by)\n\t\t\t\t VALUES ('{$stamp}', '{$projectid}', '{$listed}', '{$type}', '{$reference}', '{$expires}' , '{$created}', '{$created_by}' )"; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } return $stamp; }
/** * Creates a new pending import from a scheduled one * @param SQLIScheduledImport $scheduledImport */ public static function fromScheduledImport(SQLIScheduledImport $scheduledImport) { $pendingImport = new self(array('handler' => $scheduledImport->attribute('handler'), 'user_id' => $scheduledImport->attribute('user_id'), 'options_serialized' => $scheduledImport->attribute('options_serialized'), 'type' => self::TYPE_SCHEDULED)); $pendingImport->store(); return $pendingImport; }
static function resetStock($id, $quantity) { try { $record = new self($id); $previous_q = $record->getQuantity(); $record->setQuantity($quantity); $record->store(); $movement = new Inv_movement(); $movement->setItemId($record->getItemId()); $movement->setBranchId($record->getBranchId()); $movement->setDocumentNumber("Reset"); $movement->setQuantity($quantity - $previous_q); $movement->setDate(date('n/j/Y')); $movement->store(); } catch (fExpectedException $e) { echo $e->printMessage(); } echo $record->getQuantity(); }
/** * Set types for a role * * @param integer $role_id Role ID * @param array $current List of types assigned to role * @return boolean True on success, False on errors */ public function setTypesForRole($role_id = null, $current = null) { if (!$role_id) { $this->setError(\Lang::txt('Missing argument')); return false; } $role_id = intval($role_id); // Get an array of all the previous types $old = array(); $types = $this->getTypesForRole($role_id); if ($types) { foreach ($types as $item) { $old[] = $item->id; } } // Run through the $current array and determine if // each item is new or not $keep = array(); $add = array(); if (is_array($current)) { foreach ($current as $bit) { if (!in_array($bit, $old)) { $add[] = intval($bit); } else { $keep[] = intval($bit); } } } $remove = array_diff($old, $keep); // Remove any types in the remove list if (count($remove) > 0) { $remove = implode(',', $remove); $this->_db->setQuery("DELETE FROM {$this->_tbl} WHERE role_id=" . $this->_db->quote($role_id) . " AND type_id IN ({$remove})"); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } } // Add any types not in the OLD list if (count($add) > 0) { foreach ($add as $type) { $rt = new self($this->_db); $rt->role_id = $role_id; $rt->type_id = $type; if ($rt->check()) { $rt->store(); } } } return true; }
/** * Traitement des retours en erreur d'xml d'un praticien * * @param int $chir_id praticien de la consultation * * @return void|string */ static function traitementDossier($chir_id) { $files = array(); $fs_source_reception = CExchangeSource::get("reception-tarmed-CMediusers-{$chir_id}", "file_system", true, null, false); if (!$fs_source_reception->_id || !$fs_source_reception->active) { return null; } $count_files = CMbPath::countFiles($fs_source_reception->host); if ($count_files < 100) { try { $files = $fs_source_reception->receive(); } catch (CMbException $e) { return CAppUI::tr($e->getMessage()); } } $delfile_read_reject = CAppUI::conf("dPfacturation Other delfile_read_reject", CGroups::loadCurrent()); foreach ($files as $_file) { $fs = new CSourceFileSystem(); $rejet = new self(); $rejet->praticien_id = $chir_id; $rejet->file_name = basename($_file); if ($msg = $rejet->store()) { return $msg; } $rejet->readXML($fs->getData($_file)); //Sauvegarde du XML en CFile $new_file = new CFile(); $new_file->setObject($rejet); $new_file->file_name = basename($_file); $new_file->file_type = "application/xml"; $new_file->author_id = CAppUI::$user->_id; $new_file->fillFields(); $new_file->updateFormFields(); $new_file->forceDir(); $new_file->putContent(trim($fs->getData($_file))); if ($msg = $new_file->store()) { mbTrace($msg); } //Suppression du fichier selon configuration if ($delfile_read_reject) { $fs->delFile($_file); } } return null; }
/** * Copy all tags on an object to another object * * @param integer $oldtagid ID of tag to be copied * @param integer $newtagid ID of tag to copy to * @return boolean True if records copied */ public function copyObjects($oldtagid = null, $newtagid = null) { $oldtagid = $oldtagid ?: $this->tagid; if (!$oldtagid || !$newtagid) { return false; } $this->_db->setQuery("SELECT * FROM {$this->_tbl} WHERE tagid=" . $this->_db->quote($oldtagid)); if ($rows = $this->_db->loadObjectList()) { $entries = array(); foreach ($rows as $row) { $to = new self($this->_db); $to->objectid = $row->objectid; $to->tagid = $newtagid; $to->strength = $row->strength; $to->taggerid = $row->taggerid; $to->taggedon = $row->taggedon; $to->tbl = $row->tbl; $to->store(); $entries[] = $row->id; } require_once __DIR__ . DS . 'log.php'; $data = new stdClass(); $data->old_id = $oldtagid; $data->new_id = $newtagid; $data->entries = $entries; $log = new Log($this->_db); $log->log($newtagid, 'objects_copied', json_encode($data)); } return true; }
/** * Create a User agent entry from a US string * * @param string $ua_string User agent string * * @return self */ static function createFromUA($ua_string) { $user_agent = new self(); $user_agent->user_agent_string = substr($ua_string, 0, 255); if (!$user_agent->loadMatchingObject()) { $browser = self::detect($ua_string); $user_agent->browser_name = $browser["Browser"]; $user_agent->browser_version = $browser["Version"]; $user_agent->platform_name = $browser["Platform"]; $user_agent->platform_version = $browser["Platform_Version"]; $user_agent->device_name = $browser["Device_Name"]; $user_agent->device_maker = $browser["Device_Maker"]; $user_agent->pointing_method = $browser["Device_Pointing_Method"]; switch ($browser["Device_Type"]) { case "Mobile Device": case "Mobile Phone": $user_agent->device_type = "mobile"; break; case "Desktop": $user_agent->device_type = "desktop"; break; case "Tablet": $user_agent->device_type = "tablet"; break; default: $user_agent->device_type = "unknown"; break; } $user_agent->store(); } return $user_agent; }
/** * Duplicates the object * * - field_groups * - class_fields * - field_translations * - list_items * - ex_triggers * - (predicates) * * - host_fields * - class_messages * * - constraints * - ex_triggers * * @return null|string Store-like message */ function duplicate() { if (!$this->_id) { return null; } // Load all field values $this->load(); $new = new self(); $new->cloneFrom($this); $new->name .= " (Copie)"; $new->_dont_create_default_group = true; $this->_duplication_mapping = array(); if ($msg = $new->store()) { return $msg; } // field_groups foreach ($this->loadRefsGroups() as $_group) { if ($msg = $this->duplicateObject($_group, "ex_class_id", $new->_id, $_new_group)) { continue; } $fwd_field = "ex_group_id"; $fwd_value = $_new_group->_id; // class_fields foreach ($_group->loadRefsFields() as $_field) { $_exclude_fields = array("predicate_id", "subgroup_id"); if ($msg = $this->duplicateObject($_field, "ex_group_id", $_new_group->_id, $_new_field, $_exclude_fields)) { continue; } $_fwd_field = "ex_class_field_id"; $_fwd_value = $_new_field->_id; // field_translations $this->duplicateBackRefs($_field, "field_translations", $_fwd_field, $_fwd_value); // list_items $this->duplicateBackRefs($_field, "list_items", "field_id", $_fwd_value); // ex_triggers $this->duplicateBackRefs($_field, "ex_triggers", $_fwd_field, $_fwd_value); // predicates //$this->duplicateBackRefs($_field, "predicates", $_fwd_field, $_fwd_value); } // host_fields $this->duplicateBackRefs($_group, "host_fields", $fwd_field, $fwd_value); // class_messages $this->duplicateBackRefs($_group, "class_messages", $fwd_field, $fwd_value, array("predicate_id", "subgroup_id")); // subgroups $this->duplicateBackRefs($_group, "subgroups", "parent_id", $fwd_value, array("predicate_id", "subgroup_id")); } // ex_triggers $this->duplicateBackRefs($this, "ex_triggers", "ex_class_triggered_id", $new->_id); CExObject::clearLocales(); $this->_duplication_mapping = array(); return null; }
/** * 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; }
/** * Store the state of the patient * * @param CPatient $patient Patient * * @return null|string */ static function storeState($patient) { $identity_status = CAppUI::conf("dPpatients CPatient manage_identity_status", CGroups::loadCurrent()); //Si la configuration n'est pas activé if (!$identity_status) { return null; } $last_state = $patient->loadLastState(); if ($patient->_doubloon_ids) { $doubloons = is_array($patient->_doubloon_ids) ? $patient->_doubloon_ids : explode("|", $patient->_doubloon_ids); foreach ($doubloons as $_id) { $patient_link = new CPatientLink(); $patient_link->patient_id1 = $patient->_id; $patient_link->patient_id2 = $_id; $patient_link->loadMatchingObject(); $patient_link->store(); } } if ($last_state && $patient->status == $last_state->state) { return null; } $patient_state = new self(); $patient_state->patient_id = $patient->_id; $patient_state->state = $patient->status; $patient_state->reason = $patient->_reason_state; if ($msg = $patient_state->store()) { return $msg; } return null; }
/** * Change order * * @param integer $dir * @return mixed False if error, Object on success */ public function changeOrder($dir) { $newOrder = $this->ordering + $dir; // Load record in prev position $old = new self($this->_db); if ($old->loadByOrder($newOrder)) { $old->ordering = $this->ordering; $old->store(); } $this->ordering = $newOrder; $this->store(); return true; }
/** * Upon deletion of a class, restore all users of that class to the default class * * @param integer $id * @return boolean */ public function restoreDefaultClass($id) { include_once __DIR__ . DS . 'sessionclass.php'; $class = new SessionClass($this->_db); $class->load(array('alias' => 'default')); if (!$class->id) { return false; } $records = self::find('list', array('class_id' => $id)); if ($records && count($records) > 0) { foreach ($records as $r) { $quota = new self($this->_db); $quota->load($r->id); $quota->set('jobs', $class->jobs); $quota->set('class_id', $class->id); $quota->store(); } } return true; }
/** * Copy entry * * @return object or FALSE */ public function copyAttachment($att = NULL, $vid = NULL, $elementId = NULL, $uid = 0) { $pAttach = new self($this->_db); $pAttach->publication_id = $att->publication_id; $pAttach->title = $att->title; $pAttach->role = $att->role; $pAttach->element_id = $elementId; $pAttach->path = $att->path; $pAttach->vcs_hash = $att->vcs_hash; $pAttach->vcs_revision = $att->vcs_revision; $pAttach->object_id = $att->object_id; $pAttach->object_name = $att->object_name; $pAttach->object_instance = $att->object_instance; $pAttach->object_revision = $att->object_revision; $pAttach->type = $att->type; $pAttach->params = $att->params; $pAttach->attribs = $att->attribs; $pAttach->ordering = $att->ordering; $pAttach->publication_version_id = $vid; $pAttach->created_by = $uid; $pAttach->created = Date::toSql(); if ($pAttach->store()) { return $this->bind($pAttach); } return false; }