/** * (non-PHPdoc) * @see Syncroton_Data_IData::createEntry() */ public function createEntry($folderId, Syncroton_Model_IEntry $entry) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " create entry"); } $this->_assertContentControllerParams($folderId); $entry = $this->toTineModel($entry); // container_id gets set to personal folder in application specific controller if missing if ($folderId != $this->_specialFolderName) { $entry->container_id = $folderId; } else { $containerId = Tinebase_Core::getPreference('ActiveSync')->{$this->_defaultFolder}; if (Tinebase_Core::getUser()->hasGrant($containerId, Tinebase_Model_Grants::GRANT_ADD) === true) { $entry->container_id = $containerId; } } try { // create record (without duplicate check) // @see 0008486: Contacts deleted on Android device after new created contact via ActiveSync $this->_assertContentControllerParams($entry->container_id); $entry = $this->_contentController->create($entry, FALSE); } catch (Tinebase_Exception_AccessDenied $tead) { throw new Syncroton_Exception_AccessDenied(); } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " added entry id " . $entry->getId()); } return $entry->getId(); }
/** * add one record * * @param Tinebase_Record_Interface $_record * @return Tinebase_Record_Interface * @throws Tinebase_Exception_AccessDenied * @throws Tinebase_Exception_Record_Validation */ public function create(Tinebase_Record_Interface $_task) { $this->_handleCompleted($_task); $_task->originator_tz = $_task->originator_tz ? $_task->originator_tz : Tinebase_Core::getUserTimezone(); $task = parent::create($_task); $this->_addAutomaticAlarms($task); return $task; }
protected function _importRecord(Tinebase_Record_Abstract $_record) { if ($_record->getId()) { return $this->_controllerToImport->update($_record, false); } else { return $this->_controllerToImport->create($_record, false); } }
/** * add one record * * @param Tinebase_Record_Interface $_record * @return Tinebase_Record_Interface * @throws Tinebase_Exception_AccessDenied */ public function create(Tinebase_Record_Interface $_record) { // create a calendar for this resource $container = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => $_record->name, 'type' => Tinebase_Model_Container::TYPE_SHARED, 'backend' => $this->_backend->getType(), 'application_id' => Tinebase_Application::getInstance()->getApplicationByName($this->_applicationName)->getId())), NULL, TRUE); // remove default admin $grants = Tinebase_Container::getInstance()->setGrants($container->getId(), new Tinebase_Record_RecordSet('Tinebase_Model_Grants', array(array('account_id' => '0', 'account_type' => Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE, Tinebase_Model_Grants::GRANT_FREEBUSY => true))), TRUE, FALSE); $_record->container_id = $container->getId(); return parent::create($_record); }
/** * (non-PHPdoc) * @see Tinebase_Controller_Record_Abstract::create() */ public function create(Tinebase_Record_Interface $_record) { parent::create($_record); // after create if ($this->mustUpdateReceiptAtOnce()) { $this->updateReceipt($receiptPosition->getForeignRecord('receipt_id', Billing_Controller_Receipt::getInstance())); } return $this->get($_record->getId()); }
/** * add one record * * @param Tinebase_Record_Interface $_record * @return Sales_Model_Contract */ public function create(Tinebase_Record_Interface $_record) { // add container $_record->container_id = self::getSharedContractsContainer()->getId(); // add number $numberBackend = new Sales_Backend_Number(); $number = $numberBackend->getNext(Sales_Model_Number::TYPE_CONTRACT, $this->_currentAccount->getId()); $_record->number = $number->number; return parent::create($_record); }
/** * add one record * * @param Tinebase_Record_Interface $_record * @return Tinebase_Record_Interface * @throws Tinebase_Exception_AccessDenied */ public function create(Tinebase_Record_Interface $_record) { // create a calendar for this resource $container = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => $_record->name, 'color' => '#333399', 'type' => Tinebase_Model_Container::TYPE_SHARED, 'backend' => $this->_backend->getType(), 'application_id' => Tinebase_Application::getInstance()->getApplicationByName($this->_applicationName)->getId(), 'model' => 'Calendar_Model_Event')), NULL, TRUE); if ($_record->grants instanceof Tinebase_Record_RecordSet) { Tinebase_Container::getInstance()->setGrants($container->getId(), $_record->grants, TRUE, FALSE); } $_record->container_id = $container->getId(); return parent::create($_record); }
/** * add one record * - create new container as well * * @param Timetracker_Model_Timeaccount $_record * @return Timetracker_Model_Timeaccount * * @todo check if container name exists ? */ public function create(Tinebase_Record_Interface $_record) { $this->_checkRight('create'); // create container and add container_id to record $containerName = $_record->title; if (!empty($_record->number)) { $containerName = $_record->number . ' ' . $containerName; } $newContainer = new Tinebase_Model_Container(array('name' => $containerName, 'type' => Tinebase_Model_Container::TYPE_SHARED, 'backend' => $this->_backend->getType(), 'application_id' => Tinebase_Application::getInstance()->getApplicationByName($this->_applicationName)->getId(), 'model' => 'Timetracker_Model_Timeaccount')); $grants = new Tinebase_Record_RecordSet('Timetracker_Model_TimeaccountGrants', array(array('account_id' => Tinebase_Core::getUser()->getId(), 'account_type' => Tinebase_Acl_Rights::ACCOUNT_TYPE_USER, Timetracker_Model_TimeaccountGrants::BOOK_OWN => TRUE, Timetracker_Model_TimeaccountGrants::VIEW_ALL => TRUE, Timetracker_Model_TimeaccountGrants::BOOK_ALL => TRUE, Timetracker_Model_TimeaccountGrants::MANAGE_BILLABLE => TRUE, Tinebase_Model_Grants::GRANT_EXPORT => TRUE, Tinebase_Model_Grants::GRANT_ADMIN => TRUE))); // add container with grants (all grants for creator) and ignore ACL here $container = Tinebase_Container::getInstance()->addContainer($newContainer, $grants, TRUE); $_record->container_id = $container->getId(); $timeaccount = parent::create($_record); // save grants if (count($_record->grants) > 0) { Timetracker_Model_TimeaccountGrants::setTimeaccountGrants($timeaccount, $_record->grants); } return $timeaccount; }
/** * add entry from xml data * * @param string $_folderId * @param SimpleXMLElement $_data * @return Tinebase_Record_Abstract */ public function createEntry($_folderId, SimpleXMLElement $_entry) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " create entry"); } $entry = $this->toTineModel($_entry); $entry->creation_time = new Tinebase_DateTime($this->_syncTimeStamp); $entry->created_by = Tinebase_Core::getUser()->getId(); // container_id gets set to personal folder in application specific controller if missing if ($_folderId != $this->_specialFolderName) { $entry->container_id = $_folderId; } else { $containerId = Tinebase_Core::getPreference('ActiveSync')->{$this->_defaultFolder}; if (Tinebase_Core::getUser()->hasGrant($containerId, Tinebase_Model_Grants::GRANT_ADD) === true) { $entry->container_id = $containerId; } } $entry = $this->_contentController->create($entry); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " added entry id " . $entry->getId()); } return $entry->getId(); }
/** * (non-PHPdoc) * @see Tinebase_Controller_Record_Abstract::create() */ public function create(Tinebase_Record_Interface $_record) { // if no explicit payment method given: // inherit payment method from order, or get default $order = $_record->getForeignRecord('order_id', Billing_Controller_Order::getInstance()); if (!$_record->__get('payment_method_id')) { $paymentMethodId = Billing_Controller_PaymentMethod::getInstance()->getPaymentMethodFromRecordOrDefault($order, 'payment_method_id')->getId(); $_record->__set('payment_method_id', $paymentMethodId); } $record = parent::create($_record); /*$type = $_record->__get('type'); switch($type){ case Billing_Model_Receipt::TYPE_INVOICE: case Billing_Model_Receipt::TYPE_CREDIT: $receipt = $this->get($record->getId()); Tinebase_Event::fireEvent(new Billing_Events_BillableReceiptCreated($receipt)); break; }*/ return $record; }
/** * add one record * * @param Tinebase_Record_Interface $_record * @return Tinebase_Record_Interface * @throws Tinebase_Exception_AccessDenied */ public function create(Tinebase_Record_Interface $_record) { // check first if we already have a filter with this name for this account/application in the db $this->_sanitizeAccountId($_record); $existing = $this->search(new Tinebase_Model_PersistentFilterFilter(array('account_id' => $_record->account_id, 'application_id' => $_record->application_id, 'name' => $_record->name))); if (count($existing) > 0) { $_record->setId($existing->getFirstRecord()->getId()); $result = $this->update($_record); } else { $result = parent::create($_record); } return $result; }
/** * add one record * * @param Tinebase_Record_Interface $_record * @param bool $_checkBusyConflicts * @return Tinebase_Record_Interface * @throws Tinebase_Exception_AccessDenied * @throws Tinebase_Exception_Record_Validation */ public function create(Tinebase_Record_Interface $_record, $_checkBusyConflicts = FALSE) { try { $db = $this->_backend->getAdapter(); $transactionId = Tinebase_TransactionManager::getInstance()->startTransaction($db); $this->_inspectEvent($_record); // we need to resolve groupmembers before free/busy checking Calendar_Model_Attender::resolveGroupMembers($_record->attendee); if ($_checkBusyConflicts) { // ensure that all attendee are free $this->checkBusyConflicts($_record); } $sendNotifications = $this->_sendNotifications; $this->_sendNotifications = FALSE; $createdEvent = parent::create($_record); $this->_sendNotifications = $sendNotifications; Tinebase_TransactionManager::getInstance()->commitTransaction($transactionId); } catch (Exception $e) { Tinebase_TransactionManager::getInstance()->rollBack(); throw $e; } // send notifications if ($this->_sendNotifications && $_record->mute != 1) { $this->doSendNotifications($createdEvent, Tinebase_Core::getUser(), 'created'); } return $createdEvent; }
/** * add one record * * @param Tinebase_Record_Interface $_record * @return Tinebase_Record_Interface */ public function create(Tinebase_Record_Interface $_record) { $course = parent::create($_record); // add teacher account $i18n = Tinebase_Translation::getTranslation('Courses'); $courseName = strtolower($course->name); $loginName = strtolower($i18n->_('teacher') . '-' . $course->name); $schoolName = strtolower(Tinebase_Department::getInstance()->get($course->type)->name); $account = new Tinebase_Model_FullUser(array('accountLoginName' => $loginName, 'accountLoginShell' => '/bin/false', 'accountStatus' => 'enabled', 'accountPrimaryGroup' => $course->group_id, 'accountLastName' => $i18n->_('Teacher'), 'accountDisplayName' => $course->name . ' ' . $i18n->_('Teacher Account'), 'accountFirstName' => $course->name, 'accountExpires' => NULL, 'accountEmailAddress' => isset($this->_config->domain) && !empty($this->_config->domain) ? $loginName . '@' . $this->_config->domain : '', 'accountHomeDirectory' => isset($this->_config->basehomedir) ? $this->_config->basehomedir . $schoolName . '/' . $courseName . '/' . $loginName : '')); if (isset($this->_config->samba)) { $samUser = new Tinebase_Model_SAMUser(array('homePath' => $this->_config->samba->basehomepath . $loginName, 'homeDrive' => $this->_config->samba->homedrive, 'logonScript' => $courseName . $this->_config->samba->logonscript_postfix_teacher, 'profilePath' => $this->_config->samba->baseprofilepath . $schoolName . '\\' . $courseName . '\\' . $loginName)); $account->sambaSAM = $samUser; } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Created teacher account for course ' . $course->name . ': ' . print_r($account->toArray(), true)); } #$event = new Courses_Event_BeforeAddTeacher($account, $course); #Tinebase_Event::fireEvent($event); $password = $this->_config->get('teacher_password', $account->accountLoginName); $account = Admin_Controller_User::getInstance()->create($account, $password, $password); // add to teacher group if available if (isset($this->_config->teacher_group) && !empty($this->_config->teacher_group)) { Admin_Controller_Group::getInstance()->addGroupMember($this->_config->teacher_group, $account->getId()); } // add to students group if available if (isset($this->_config->students_group) && !empty($this->_config->students_group)) { Admin_Controller_Group::getInstance()->addGroupMember($this->_config->students_group, $account->getId()); } return $course; }