Ejemplo n.º 1
0
 public function updateUserInfo($user_id, $post, $user_photo, $user_cover)
 {
     if (!empty($user_photo)) {
         $user_photo_res = Yii::app()->request->getBaseUrl(true) . '/' . $user_photo;
     }
     if (!empty($user_cover)) {
         $user_cover_res = Yii::app()->request->getBaseUrl(true) . '/' . $user_cover;
     }
     $model = User::model()->findByAttributes(array('id' => $user_id));
     $model->setAttributes($post);
     //echo $user_photo; die;
     if (!empty($user_photo_res)) {
         $photo = ImageResize::resize_image($user_photo_res, '', 128, 128, false, 'avatar', false, false, 100);
         $model->photo = $photo;
     }
     if (!empty($user_cover_res)) {
         $cover = ImageResize::resize_image($user_cover_res, '', 1800, 1200, false, 'cover', false, false, 80);
         $model->cover = $cover;
     }
     $model->updated_at = time();
     if ($model->save(FALSE)) {
         return TRUE;
     }
     return FALSE;
 }
 /**
 * to get the images
 * @return $array_of_images having path for all type of images
 *
   DEPRECATED
 * NOTE: you should probably be using uihelper_resize_mk_img() or
 * uihelper_resize_mk_user_img() to resize images.
 */
 public static function get_images($image_path, $desktop_image = 0)
 {
     Logger::log("Enter: ImageResize::get_images");
     // global var $path_prefix has been removed - please, use PA::$path static variable
     $array_of_images[] = array();
     $path = explode('/', $image_path);
     $image_name = end($path);
     $path1 = explode('.', $image_path);
     $ext = strtolower(end($path1));
     if ($desktop_image == 1) {
         $array_of_images['original_image'] = "{$image_path}";
         $d_path = DESKTOP . "{$image_name}";
         if (!file_exists("{$d_path}")) {
             ImageResize::resize_image($image_path, $desktop_image);
         }
         $array_of_images['desktop_image'] = $d_path;
         $t = $array_of_images['desktop_image'];
         //print "$image_path(($desktop_image)) $t"; exit;
     } else {
         $m_path = MEDIUM . "{$image_name}";
         $s_path = SMALL . "{$image_name}";
         $vs_path = VERY_SMALL . "{$image_name}";
         $t_path = THUMBNAIL . "{$image_name}";
         $array_of_images['original_image'] = "{$image_path}";
         if (!file_exists("{$m_path}") || !file_exists("{$s_path}") || !file_exists("{$vs_path}") || !file_exists("{$t_path}")) {
             ImageResize::resize_image($image_path);
         }
         $array_of_images['medium_image'] = $m_path;
         $array_of_images['small_image'] = $s_path;
         $array_of_images['verysmall_image'] = $vs_path;
         $array_of_images['thumbnail_image'] = $t_path;
     }
     return $array_of_images;
     Logger::log("Exit: ImageResize::get_images");
 }