Ejemplo n.º 1
0
 public function addpictureAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->getHelper("layout")->disableLayout();
     $this->getFileUploadScript();
     $oUploadHandler = new AppCms2_UploadHandler();
     $oUserParam = new Admin_Model_UserParam();
     if ($this->_request->isPost()) {
         $aResult = $oUploadHandler->post();
         if (!isset($aResult["files"][0]->error)) {
             $aPostData = $this->_request->getPost();
             $nUserId = (int) $aPostData["add_photo_user_id"];
             $nMediaWidth = $aPostData["media_width"];
             $nMediaHeight = $aPostData["media_height"];
             $sUserName = $aResult["files"][0]->name;
             $sGenName = $aResult["files"][0]->gen_name;
             if (!is_dir($this->_sPath . "user_id_" . $nUserId)) {
                 if (!mkdir($this->_sPath . "user_id_" . $nUserId, 0777)) {
                     throw new Zend_Exception();
                 }
             }
             $oImagic = new AppCms2_Imagick($this->_sPath . $sUserName);
             if (isset($nMediaWidth) && isset($nMediaHeight)) {
                 $oImagic->cropimage((int) $nMediaWidth, (int) $nMediaHeight, 0, 0);
             }
             $oImagic->writeImage($this->_sPath . "user_id_" . $nUserId . "/normal_" . $sGenName);
             $oImagic->cropThumbnailImage(70, 100);
             $oImagic->writeImage($this->_sPath . "user_id_" . $nUserId . "/min_" . $sGenName);
             $oImagic->writeImage($this->_sPath . "thumbnail/" . $sGenName);
             unlink($this->_sPath . $sUserName);
             if (file_exists($this->_sPath . $sUserName)) {
                 throw new Zend_Exception();
             }
             $oModelImage = new Admin_Model_Image();
             $nImageId = $oModelImage->saveImage(3, null, $sGenName, $sUserName);
             $oUserParam->editImageUserParam($nUserId, $nImageId);
         } else {
             $sUserName = $aResult["files"][0]->name;
             unlink($this->_sPath . $sUserName);
         }
         $oModelImage->deleteUnused();
     }
     exit;
 }
Ejemplo n.º 2
0
 public function newUserFb($aParam)
 {
     if (is_array($aParam) && count($aParam)) {
         $nUserId = $this->findUserByEmailAddress($aParam["email"]);
         if ($nUserId) {
             $this->editRow($nUserId, array("user_fb_id" => $aParam["id"]));
             $aRow = $this->findUser($nUserId);
             return $aRow;
         } else {
             $oModelUserParm = new Admin_Model_UserParam();
             try {
                 $this->_db->beginTransaction();
                 $oRow = $this->createRow();
                 if ($oRow instanceof Zend_Db_Table_Row_Abstract) {
                     $oRow->user_role_id = 5;
                     $oRow->user_fb_id = $aParam["id"];
                     $oRow->email_address = $aParam["email"];
                     $oRow->created_date = time();
                     $oRow->is_active = 2;
                     $nUserId = $oRow->save();
                     if ($oModelUserParm->newUserParam($nUserId, $aParam)) {
                         $this->_db->commit();
                         return $oRow->toArray();
                     }
                 }
             } catch (Zend_Exception $e) {
                 $this->_db->rollBack();
                 return null;
             }
         }
     }
     return null;
 }