当前位置: 首页>>代码示例>>PHP>>正文


PHP Term::save方法代码示例

本文整理汇总了PHP中Term::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Term::save方法的具体用法?PHP Term::save怎么用?PHP Term::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Term的用法示例。


在下文中一共展示了Term::save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute(CommandContext $context)
 {
     $term = new Term(Term::getSelectedTerm());
     $term->setDocusignTemplate($context->get('template'));
     $term->setDocusignUnder18Template($context->get('under18_template'));
     $term->save();
     $cmd = CommandFactory::getCommand('ShowEditTerm');
     $cmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:9,代码来源:SaveTermSettingsCommand.php

示例2: execute

 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'banner_queue')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to enable/disable the Banner queue.');
     }
     if (is_null($this->term)) {
         $this->term = $context->get('term');
     }
     $term = $this->term;
     if (is_null($term)) {
         throw new InvalidArgumentException('No term was specified to DisableBannerQueue');
     }
     $term = new Term($term);
     if (!$term->getBannerQueue()) {
         NQ::Simple('hms', hms\NotificationView::ERROR, 'The Banner Queue is not enabled for ' . Term::toString($term->term) . '.');
     } else {
         if ($term->getQueueCount() < 1) {
             NQ::Simple('hms', hms\NotificationView::WARNING, 'The Banner Queue was already empty for ' . Term::toString($term->term) . '.');
             $term->setBannerQueue(FALSE);
             $term->save();
             NQ::Simple('hms', hms\NotificationView::SUCCESS, 'Banner Queue has been disabled for ' . Term::toString($term->term) . '.');
         } else {
             PHPWS_Core::initModClass('hms', 'BannerQueue.php');
             $result = BannerQueue::processAll($term->term);
             if ($result === TRUE) {
                 NQ::Simple('hms', hms\NotificationView::SUCCESS, 'Banner Queue has been processed for ' . Term::toString($term->term) . '.');
                 $term->setBannerQueue(FALSE);
                 $term->save();
                 NQ::Simple('hms', hms\NotificationView::SUCCESS, 'Banner Queue has been disabled for ' . Term::toString($term->term) . '.');
             } else {
                 // TODO: This is just awful.
                 $text = 'The following failures occurred reporting to Banner:<br /><br /><ul>';
                 foreach ($result as $error) {
                     $text .= "<li>{$error['username']}: ({$error['code']}) - {$error['message']}</li>";
                 }
                 $text .= '</ul>The queue was not disabled.';
                 NQ::Simple('hms', hms\NotificationView::ERROR, $text);
             }
         }
     }
     $cmd = CommandFactory::getCommand('ShowEditTerm');
     $cmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:44,代码来源:ProcessBannerQueueCommand.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Term();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Term'])) {
         $model->attributes = $_POST['Term'];
         if ($model->save()) {
             $this->redirect(array('admin'));
         }
     }
     $cs = Yii::app()->getClientScript();
     $js = $this->generateJs();
     $cs->registerScript('term_', $js, CClientScript::POS_READY);
     $this->render('create', array('model' => $model, 'listData' => array(0 => '-- Chọn cấp cha --')));
 }
开发者ID:ngdvan,项目名称:lntguitar,代码行数:20,代码来源:TermController.php

示例4: execute

 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'banner_queue')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to enable/disable the Banner queue.');
     }
     if (is_null($this->term)) {
         $this->term = $context->get('term');
     }
     $term = $this->term;
     if (is_null($term)) {
         throw new InvalidArgumentException('No term was specified to DisableBannerQueue');
     }
     $term = new Term($term);
     $term->setBannerQueue(TRUE);
     $term->save();
     NQ::Simple('hms', hms\NotificationView::SUCCESS, 'Banner Queue has been enabled for ' . Term::toString($term->term) . '.');
     CommandContext::goBack();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:19,代码来源:EnableBannerQueueCommand.php

示例5: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aTerm !== null) {
             if ($this->aTerm->isModified() || $this->aTerm->isNew()) {
                 $affectedRows += $this->aTerm->save($con);
             }
             $this->setTerm($this->aTerm);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->coursesScheduledForDeletion !== null) {
             if (!$this->coursesScheduledForDeletion->isEmpty()) {
                 CourseQuery::create()->filterByPrimaryKeys($this->coursesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->coursesScheduledForDeletion = null;
             }
         }
         if ($this->collCourses !== null) {
             foreach ($this->collCourses as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:therealchiko,项目名称:getchabooks,代码行数:54,代码来源:BaseDept.php

示例6: addTerm

 public function addTerm($term_name, $category = false)
 {
     if (is_numeric($term_name)) {
         $term = TermPeer::retrieveByPk($term_name);
     } else {
         $slug = sfPropelActAsSluggableBehaviorUtils::stripText(ForgeToolkit::normalizeTag($term_name), '_');
         $term = TermPeer::retrieveBySlug($slug);
     }
     if (!$term) {
         $term = new Term();
         $term->setTitle(ForgeToolkit::normalizeTag($term_name));
         $term->setCategory(false);
         $term->save();
     }
     try {
         $rel = new TermRelationship();
         $rel->setTerm($term);
         $rel->setPlugin($this);
         $rel->save();
     } catch (PropelException $e) {
         // avoid duplicates
     }
 }
开发者ID:nageshwar545,项目名称:PluginsKit,代码行数:23,代码来源:Plugin.php

示例7: execute

 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'edit_terms')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to edit terms.');
     }
     $successCmd = CommandFactory::getCommand('ShowEditTerm');
     $errorCmd = CommandFactory::getCommand('ShowCreateTerm');
     $year = $context->get('year_drop');
     $sem = $context->get('term_drop');
     if (!isset($year) || is_null($year) || empty($year)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You must provide a year.');
         $errorCmd->redirect();
     }
     if (!isset($sem) || is_null($sem) || empty($sem)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You must provide a semester.');
         $errorCmd->redirect();
     }
     // Check to see if the specified term already exists
     if (!Term::isValidTerm($year . $sem)) {
         $term = new Term(NULL);
         $term->setTerm($year . $sem);
         $term->setBannerQueue(1);
         try {
             $term->save();
         } catch (DatabaseException $e) {
             NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error saving the term. Please try again or contact ESS.');
             $errorCmd->redirect();
         }
     } else {
         $term = new Term($year . $sem);
         // The term already exists, make sure there are no halls for this term
         $db = new PHPWS_DB('hms_residence_hall');
         $db->addWhere('term', $term->getTerm());
         $num = $db->count();
         if (!is_null($num) && $num > 0) {
             NQ::simple('hms', hms\NotificationView::ERROR, 'One or more halls already exist for this term, so nothing can be copied.');
             $errorCmd->redirect();
         }
     }
     $text = Term::toString($term->getTerm());
     $copy = $context->get('copy_pick');
     $copyAssignments = false;
     $copyRoles = false;
     // If you want to copy roles and/or assignments
     // you must also copy the hall structure.
     if (isset($copy['struct'])) {
         // Copy hall structure
         if (isset($copy['assign'])) {
             // Copy assignments.
             $copyAssignments = true;
         }
         if (isset($copy['role'])) {
             // Copy roles.
             $copyRoles = true;
         }
     } else {
         // either $copy == 'nothing', or the view didn't specify... either way, we're done
         NQ::simple('hms', hms\NotificationView::SUCCESS, "{$text} term created successfully.");
         $successCmd->redirect();
     }
     # Figure out which term we're copying from, if there isn't one then use the "current" term.
     $fromTerm = $context->get('from_term');
     if (is_null($fromTerm)) {
         $fromTerm = Term::getCurrentTerm();
     }
     PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     $db = new PHPWS_DB();
     try {
         $db->query('BEGIN');
         # Get the halls from the current term
         $halls = HMS_Residence_Hall::get_halls($fromTerm);
         set_time_limit(36000);
         foreach ($halls as $hall) {
             $hall->copy($term->getTerm(), $copyAssignments, $copyRoles);
         }
         $db->query('COMMIT');
     } catch (Exception $e) {
         $db->query('ROLLBACK');
         PHPWS_Error::log(print_r($e, true), 'hms');
         NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error copying the hall structure and/or assignments. The term was created, but nothing was copied.');
         $errorCmd->redirect();
     }
     if ($copyAssignments) {
         NQ::simple('hms', hms\NotificationView::SUCCESS, "{$text} term created successfully. The hall structure and assignments were copied successfully.");
     } else {
         NQ::simple('hms', hms\NotificationView::SUCCESS, "{$text} term created successfully and hall structure copied successfully.");
     }
     Term::setSelectedTerm($term->getTerm());
     $successCmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:92,代码来源:CreateTermCommand.php

示例8: doTermUpdate

 /**
  * Update term in database.
  * The DB needs to be kept two terms ahead
  * of the current term.
  */
 public static function doTermUpdate()
 {
     /* Keep inserting next term until there are currentTerm+3 in DB */
     while (self::isTimeToUpdate()) {
         /* Insert new term adjacent to latest one in DB. */
         $db = self::getDb();
         $db->addOrder('term desc');
         $result = $db->select('row');
         // Get first row (Max).
         /* Just log if it's an error. User can resume their work.*/
         if (\PHPWS_Error::logIfError($result)) {
             return null;
         }
         // Be quiet.
         if (sizeof($result) == 0) {
             /* If there is nothing in database insert the current Term! */
             $term = new Term();
             $term->term = self::timeToTerm(time());
             $term->save();
         } else {
             $termStr = strval($result['term']);
             $year = substr($termStr, 0, 4);
             $semester = substr($termStr, 4, 1);
             /* Increment semester. This just flips back around to 1 if semester is 4. */
             $semester = intval($semester) % 4 + 1;
             /* If new semester is '1' then it's a new year also! */
             if ($semester == 1) {
                 //Increment year.
                 $year = intval($year) + 1;
             }
             /* Create new term and save it */
             $term = new Term();
             $term->term = $year . $semester;
             $term->save();
         }
     }
 }
开发者ID:jlbooker,项目名称:InternshipInventory,代码行数:42,代码来源:Term.php


注:本文中的Term::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。