Esempio n. 1
0
 public function createpostAction()
 {
     $_e = new Common_Data_Entry_Type();
     $item = array('typeid' => $this->_params['typeid'], 'title' => $this->_params['title'], 'summary' => $this->_params['summary']);
     try {
         $_e->insert($item);
     } catch (Exception $e) {
         throw $e;
     }
     $links = array(array('title' => 'Manage Fields', 'url' => '/wcm/type-admin/fields?typeid=' . $item['typeid']), array('title' => 'Content Types', 'url' => '/wcm/type-admin/'));
     $this->view->message = Common_Message::get('success', 'Success', $links);
     $this->render('message-block', null, true);
 }
Esempio n. 2
0
 public function uppostAction()
 {
     foreach ($this->_params as $key => $value) {
         $this->view->{$key} = $value;
     }
     $_validator = new Common_User_Sign_UpValidate();
     if (!$_validator->isValid($this->_params, $msg)) {
         $this->view->message = Common_Message::get('error', $msg);
         return $this->indexAction();
     }
     try {
         $_sign = new Common_User_Sign();
         $_sign->up($this->_params);
         $links = array(array('url' => $this->view->baseModulePath . '/sign', 'title' => 'Sign in'));
         $this->view->message = Common_Message::get('success', 'Success', $links);
         $this->render('message', null, true);
     } catch (Exception $e) {
         $this->view->message = Common_Message::get('error', $e->getMessage());
         return $this->indexAction();
     }
 }
Esempio n. 3
0
 public function emaildoAction()
 {
     $params = $this->_params;
     if (User_Model_Account_EmailValidate::isValid($params, $msg)) {
         try {
             if ($this->_session->uid != "0") {
                 $_user = new Common_Db_User();
                 //$user = $_user->getById($this->_session->uid);
                 $set = array('email' => $params['email']);
                 $where = array('uid = ?' => $this->_session->uid);
                 $_user->update($set, $where);
                 $this->view->message = Common_Message::get('success', 'Success');
             }
         } catch (Exception $e) {
             $this->view->message = Common_Message::get('error', 'Unknown');
         }
     } else {
         $this->view->message = Common_Message::get('error', $msg);
     }
     $this->loadLayout('layout-simple');
     $this->render('email');
 }
Esempio n. 4
0
 public function photodoAction()
 {
     $params = $this->_params;
     $_user = new Common_Db_User();
     $_image = new Common_Util_Image();
     $status = true;
     $profile = null;
     try {
         if ($this->_session->uid != "0") {
             $profile = $_user->getById($this->_session->uid);
         }
     } catch (Exception $e) {
         //
     }
     if ($profile === null) {
         $msg = Common_Message::get('error', 'Unknown error');
     } else {
         $file_tmp = $_FILES['attachment']['tmp_name'];
         $file_name = $_FILES['attachment']['name'];
         $file_size = $_FILES['attachment']['size'];
         $file_mime = $_FILES['attachment']['type'];
         $file_ext = substr(strrchr(strtolower($file_name), '.'), 1);
         if (!in_array($file_ext, array('png', 'jpg', 'jpeg', 'gif'))) {
             $msg = Common_Message::get('error', 'You must upload a JPG, GIF, or PNG file');
         } else {
             if (is_uploaded_file($file_tmp)) {
                 $des = str_split($profile['uname']);
                 $des_dir = SYS_ENTRY . '/data/user/' . $des['0'] . '/' . $des['1'] . '/' . $des['2'];
                 $des_dir .= '/' . $profile['uname'];
                 Common_Util_Directory::mkdir($des_dir);
                 $file_size_stored = @filesize($file_tmp);
                 if ($file_size_stored > 1000000) {
                     @unlink($file_tmp);
                     $max_size = 1000000 / 1000;
                     $msg = Common_Message::get('error', "File size must less than {$max_size} Kb");
                     $status = false;
                 } elseif ($file_size_stored != $file_size) {
                     @unlink($file_tmp);
                     $msg = Common_Message::get('error', 'Unknown error');
                     $status = false;
                 }
                 if ($status && ($imginfo = @getimagesize($file_tmp))) {
                     if (!$imginfo[2]) {
                         @unlink($file_tmp);
                         $msg = Common_Message::get('error', 'Invalid image');
                         $status = false;
                     }
                 }
                 $_image->resampimagejpg(100, 100, $file_tmp, $des_dir . '/w100.png', true);
                 $_image->resampimagejpg(40, 40, $file_tmp, $des_dir . '/w40.png', false);
             }
         }
     }
     if (isset($msg)) {
         $this->view->message = $msg;
     } else {
         $this->view->message = Common_Message::get('success', 'Success');
     }
     $this->loadLayout('layout-simple');
     $this->render('photo');
     //$this->_redirect('/user/manage');
 }