示例#1
0
 public function update($validate = true, $attributes = null)
 {
     $ret_val = false;
     switch (is_array($this->_update)) {
         case true:
             $this->logText = "";
             foreach ($this->_update as $data) {
                 $model = Token::find($data['unique']);
                 switch ($model instanceof Token) {
                     case true:
                         $model->setScenario('update');
                         $model->load($data['data']);
                         switch ($model->validate()) {
                             case true:
                                 $model->save();
                                 $this->logText .= \nitm\models\DB::split_c(array_keys($data['data']), array_values($data['data']), '=', ',', false, false, false) . "\n";
                                 break;
                         }
                         break;
                 }
             }
             $this->messages .= "Updated " . sizeof($this->_update) . " tokens for user with ID " . $this->user_id;
             $this->log(static::tableName(), 'Update Tokens', $this->message . ". Tokens:\n" . $this->logText);
             $ret_val = true;
             break;
     }
     return $ret_val;
 }
 /**
  * Generates a token for a specific user
  * @param integer $id
  * @return string
  */
 public function actionGenerate()
 {
     $token = new Token();
     return $token->getUniqueToken((int) $id);
 }