예제 #1
0
 public function updateAction()
 {
     $userid = $this->_request->getParam('user_id');
     $imagepath = $this->_request->getParam('profile_photo');
     if ($imagepath != '') {
         if (file_exists(USER_PREVIEW_UPLOAD_PATH . '//' . $imagepath)) {
             copy(USER_PREVIEW_UPLOAD_PATH . '//' . $imagepath, USER_UPLOAD_PATH . '//' . $imagepath);
             unlink(USER_PREVIEW_UPLOAD_PATH . '//' . $imagepath);
         }
     }
     $usermodel = new Default_Model_Users();
     $data = array('profileimg' => $imagepath);
     $where = array("id=?" => $userid);
     $status = $usermodel->addOrUpdateProfileImage($data, $where);
     if ($status == 'update') {
         $update_query = "update main_employees_summary set profileimg = '" . $imagepath . "',\n                             modifieddate = utc_timestamp() where user_id = '" . $userid . "'";
         $db = Zend_Db_Table::getDefaultAdapter();
         $result = $db->query($update_query);
         $auth = Zend_Auth::getInstance();
         if ($auth->hasIdentity()) {
             $auth->getStorage()->read()->profileimg = $imagepath;
         }
     }
     $this->_helper->json($status);
 }