예제 #1
0
 /**
  * 保存设置
  */
 public function saveAction()
 {
     $action = $this->_request->getPost('action');
     $post = $this->_request->getPost();
     if (empty($post['orgname'])) {
         return $this->json(false, '请输入组织简称');
     }
     if (!empty($post['intro']) && Oray_Function::strLen($post['intro']) > 300) {
         return $this->json(false, '组织简介长度请控制在300字符以内');
     }
     /* @var $modelOrg Model_Org_Org*/
     $modelOrg = Tudu_Model::factory('Model_Org_Org');
     try {
         $modelOrg->execute('info', array(array('orgid' => $this->_orgId, 'entirename' => $post['entirename'])));
         $modelOrg->execute('updateOrg', array(array('orgid' => $this->_orgId, 'orgname' => $post['orgname'], 'intro' => $post['intro'])));
     } catch (Model_Org_Exception $e) {
         switch ($e->getCode()) {
             case Model_Org_Org::CODE_INVALID_ORGID:
                 $message = '缺少参数[orgid]';
                 break;
             case Model_Org_Org::CODE_ORG_NOTEXISTS:
                 $message = '组织不存在或已被删除';
                 break;
             case Model_Org_Org::CODE_INVALID_ORGNAME:
                 $message = '请输入组织简称';
                 break;
             case Model_Org_Org::CODE_SAVE_FAILED:
                 $message = '更新组织信息失败';
                 break;
         }
         return $this->json(false, $message);
     }
     $this->_cleanCache();
     return $this->json(true, '更新企业信息成功');
 }