예제 #1
0
 /**
  * 更新标签
  */
 public function updateAction()
 {
     $labelId = $this->_request->getPost('labelid');
     $post = Oray_Function::trim($this->_request->getPost());
     if (!$labelId) {
         return $this->json(false, $this->lang['invalid_labelid']);
     }
     $label = null;
     foreach ($this->getLabels() as $_label) {
         if ($_label['labelid'] == $labelId) {
             $label = $_label;
             break;
         }
     }
     if (null === $label || $label['issystem']) {
         return $this->json(false, $this->lang['deny_system_label']);
     }
     $params = array();
     if (!empty($post['name']) && $label['labelalias'] != $post['name']) {
         $this->_checkLabel($post['name']);
         $params['labelalias'] = $post['name'];
     }
     if (!empty($post['bgcolor'])) {
         $params['bgcolor'] = $post['bgcolor'];
     }
     if (!$params) {
         $this->json(true, $this->lang['label_update_success']);
     }
     $daoLabel = $this->getDao('Dao_Td_Tudu_Label');
     $daoLabel->updateLabel($this->_user->uniqueId, $labelId, $params);
     $this->_labels = null;
     $labels = $this->getLabels();
     return $this->json(true, $this->lang['label_update_success'], $labels);
 }