public function testProfileChange() { Yii::import('application.modules.users.models.*'); $this->adminLogin(); // Set empty profile data $this->open('users/profile'); $this->type('UserProfile[full_name]', ''); $this->type('User[email]', ''); $this->clickAtAndWait("//input[@type='submit' and @value='Сохранить']"); $this->assertTrue($this->isTextPresent('Необходимо заполнить поле «Полное Имя»')); $this->assertTrue($this->isTextPresent('Необходимо заполнить поле «Email»')); // Set normal random data $time = time(); $this->type('UserProfile[full_name]', 'fullname' . $time); $this->type('User[email]', 'admin.' . $time . '@localhost.loc'); $this->clickAtAndWait("//input[@type='submit' and @value='Сохранить']"); $this->assertTrue($this->isTextPresent('Изменения успешно сохранены.')); // Check if data really saved $profile = UserProfile::model()->findByAttributes(array('user_id' => 1)); $user = User::model()->findByAttributes(array('id' => 1)); $this->assertTrue($profile->full_name == 'fullname' . $time); $this->assertTrue($user->email == 'admin.' . $time . '@localhost.loc'); // Change password $this->type('ChangePasswordForm[current_password]', 'admin'); $this->type('ChangePasswordForm[new_password]', 'admin'); $this->clickAtAndWait("//input[@type='submit' and @value='Изменить']"); $this->assertTrue($this->isTextPresent('Пароль успешно изменен.')); // Try to set wrong password $this->type('ChangePasswordForm[current_password]', mt_rand(1, 10)); $this->clickAtAndWait("//input[@type='submit' and @value='Изменить']"); $this->assertTrue($this->isTextPresent('Ошибка проверки текущего пароля')); }
public function actionShow($id, $mid) { //$photos = Photos::model(); //$photo = $photos->findByPk($mid); $ap = Bookmarks::model()->findAll(array('select' => 'content_id', 'condition' => 'owner_id = :id AND type = 1', 'params' => array(':id' => $id))); $count = count($ap); foreach ($ap as $ind => $ph) { if ($ph['content_id'] == $mid) { $num = $ind + 1; if ($ind == 0) { $prev = $ap[$count - 1]['content_id']; } else { $prev = $ap[$ind - 1]['content_id']; } if ($ind == $count - 1) { $next = $ap[0]['content_id']; } else { $next = $ap[$ind + 1]['content_id']; } } } $aroundInfo = array('num' => $num, 'count' => $count, 'prev' => $prev, 'next' => $next); $myProfile = UserProfile::model()->getUserProfile(Yii::app()->user->id); $myPage = $id == Yii::app()->user->id; $comments = Comments::model()->getLast('photos', $mid, 10); $comments = array_reverse($comments); $photo = Photos::model()->findByPk($mid); $this->renderPartial('_show_photo', array('photo' => $photo, 'nav_link' => 'show', 'user_id' => $id, 'aroundInfo' => $aroundInfo, 'myProfile' => $myProfile, 'myPage' => $myPage, 'comments' => $comments, 'comments_tbl' => 'photos')); }
public function actionShowPosts($id, $mid, $sid) { $posts = Posts::model()->findByPk($sid); $multimedia = json_decode($posts->multimedia); $count = count($multimedia); foreach ($multimedia as $ind => $file) { if ($file->nomber == $mid) { $num = $ind + 1; if ($ind == 0) { $prev = $multimedia[$count - 1]->nomber . '/' . $sid; } else { $prev = $multimedia[$ind - 1]->nomber . '/' . $sid; } if ($ind == $count - 1) { $next = $multimedia[0]->nomber . '/' . $sid; } else { $next = $multimedia[$ind + 1]->nomber . '/' . $sid; } $current_photo = $file; } } $myPage = $id == Yii::app()->user->id; $myProfile = UserProfile::model()->getUserProfile(Yii::app()->user->id); $ext = Files::model()->findByPk($current_photo->id)->extension; $aroundInfo = array('num' => $num, 'count' => $count, 'prev' => $prev, 'next' => $next); $comments = Comments::model()->getLast('posts_' . $sid, $mid, 10); $comments = array_reverse($comments); $file = array('id' => $current_photo->id, 'file' => $current_photo->id, 'image' => array('extension' => $ext), 'description' => '', 'upload_date' => $current_photo->upload_date); $this->renderPartial('show_photo', array('photo' => $file, 'nav_link' => 'showposts', 'user_id' => $id, 'aroundInfo' => $aroundInfo, 'myProfile' => $myProfile, 'myPage' => $myPage, 'comments' => $comments, 'comments_tbl' => 'posts_' . $sid, 'comments_item_id' => $mid)); }
public function actionProfile() { $id = Yii::app()->user->id; if (!isset($_SESSION['filemanager'])) { $_SESSION['filemanager'] = true; } $_SESSION['currentFolder'] = 'user/'; $model = $this->loadModel($id); $modelProfile = UserProfile::model()->exists('userid=' . $id) ? UserProfile::model()->findByPk($id) : new UserProfile(); $role = Yii::app()->request->getPost('role'); $postUser = Yii::app()->request->getPost('User'); $postProfile = Yii::app()->request->getPost('UserProfile'); if (isset($postUser) && isset($postProfile)) { Yii::import('application.modules.backend.controllers.UserController'); //do hàm contruct của UserController(extends controllers) lỗi ko cho phép null iduser nên thêm vào để ko xảy ra lỗi này //mục đích là dùng dc hàm saveUserInfo trong UserController nên ko ảnh hưởng gì $UserControllerTemp = new UserController(2); if ($UserControllerTemp->saveUserInfo($model, $modelProfile, $postUser, $postProfile, $role, false)) { Yii::app()->user->setFlash('success', Yii::t('user', 'Update user\'s info successfully.')); } else { Yii::app()->user->setFlash('error', Yii::t('user', 'Update user\'s info fail. Please try it later.')); } } $this->render('profile', array('model' => $model, 'modelProfile' => $modelProfile, 'role' => User::model()->getRoleUser($model->id))); }
function actionDeleteuser($id) { $user = User::model()->findByPk($id); $userProfile = UserProfile::model()->find('user_id=:id', array(':id' => $id)); $userProfile->delete(); $user->delete(); $this->redirect(array('admin/index')); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = UserProfile::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionIndex($id) { Yii::app()->clientScript->registerScript('global_user_id', 'var glUserId = ' . $id . ';', CClientScript::POS_HEAD); $user = UserProfile::model()->getUserProfile($id); $myPage = Yii::app()->user->id == $id; $videos = Videos::model()->findAll('user_id=:id', array(':id' => $id)); $videos_count = count($videos); $this->render('index', array('profile' => $user, 'myPage' => $myPage, 'videos' => $videos, 'videos_count' => $videos_count)); }
public static function getDistrictBYUserid($user_id) { $value = UserProfile::model()->findByAttributes(array('user_id' => $user_id)); if (empty($value->district_id)) { return 13; } else { return $value->district_id; } }
public function actionAdd() { MainUtil::checkLicenseLimit(); if (EnvUtil::submitCheck("userSubmit")) { $origPass = filter_input(INPUT_POST, "password", FILTER_SANITIZE_STRING); $_POST["salt"] = StringUtil::random(6); $_POST["password"] = !empty($origPass) ? md5(md5($origPass) . $_POST["salt"]) : ""; $_POST["createtime"] = TIMESTAMP; $_POST["guid"] = StringUtil::createGuid(); $this->dealWithSpecialParams(); $data = User::model()->create(); $newId = User::model()->add($data, true); if ($newId) { UserCount::model()->add(array("uid" => $newId)); $ip = Ibos::app()->setting->get("clientip"); UserStatus::model()->add(array("uid" => $newId, "regip" => $ip, "lastip" => $ip)); UserProfile::model()->add(array("uid" => $newId)); if (!empty($_POST["auxiliarydept"])) { $deptIds = StringUtil::getId($_POST["auxiliarydept"]); $this->handleAuxiliaryDept($newId, $deptIds, $_POST["deptid"]); } if (!empty($_POST["auxiliarypos"])) { $posIds = StringUtil::getId($_POST["auxiliarypos"]); $this->handleAuxiliaryPosition($newId, $posIds, $_POST["positionid"]); } $newUser = User::model()->fetchByPk($newId); $users = UserUtil::loadUser(); $users[$newId] = UserUtil::wrapUserInfo($newUser); User::model()->makeCache($users); OrgUtil::update(); OrgUtil::hookSyncUser($newId, $origPass, 1); $this->success(Ibos::lang("Save succeed", "message"), $this->createUrl("user/index")); } else { $this->error(Ibos::lang("Add user failed"), $this->createUrl("user/index")); } } else { $deptid = ""; $manager = ""; $account = Ibos::app()->setting->get("setting/account"); if ($account["mixed"]) { $preg = "[0-9]+[A-Za-z]+|[A-Za-z]+[0-9]+"; } else { $preg = "^[A-Za-z0-9\\!\\@\\#\$\\%\\^\\&\\*\\.\\~]{" . $account["minlength"] . ",32}\$"; } if ($deptid = EnvUtil::getRequest("deptid")) { $deptid = StringUtil::wrapId(EnvUtil::getRequest("deptid"), "d"); $manager = StringUtil::wrapId(Department::model()->fetchManagerByDeptid(EnvUtil::getRequest("deptid")), "u"); } $this->setPageTitle(Ibos::lang("Add user")); $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Organization"), "url" => $this->createUrl("department/index")), array("name" => Ibos::lang("User manager"), "url" => $this->createUrl("user/index")), array("name" => Ibos::lang("Add user")))); $this->render("add", array("deptid" => $deptid, "manager" => $manager, "passwordLength" => $account["minlength"], "preg" => $preg)); } }
public function init() { if (!Yii::app()->user->isGuest) { if (is_null($this->user_id)) { $this->user_id = Yii::app()->user->id; } //TODO: store name in session $this->me = UserProfile::model()->find('user_id=:iid', array(':iid' => Yii::app()->user->id)); } if (!is_null($this->user_id)) { $this->users = $this->me->getFriends(); } }
/** * Authenticates a user. * The example implementation makes sure if the username and password * are both 'demo'. * In practical applications, this should be changed to authenticate * against some persistent user identity storage (e.g. database). * @return boolean whether authentication succeeds. */ public function authenticate() { // find user record by email address (username) $UserLogin = UserLogin::model()->findByAttributes(array('LoginEmail' => $this->username, 'IsActive' => 1)); if ($UserLogin === null) { $this->errorCode = self::ERROR_USERNAME_INVALID; } else { if ($UserLogin->UserPassword !== md5($this->password)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->errorCode = self::ERROR_NONE; // set user login ID $this->userLoginID = $UserLogin->UserLoginID; // assign user role in auth manager $userRole = UserRole::model()->findByPk($UserLogin->UserRoleID)->RoleType; $currentRoles = Yii::app()->authManager->getRoles($this->userLoginID); if (!array_key_exists($userRole, $currentRoles)) { // remove old role if role changes if (!empty($currentRoles)) { AuthAssignment::model()->deleteAll('userid = :userid', array('userid' => $this->userLoginID)); } Yii::app()->authManager->assign($userRole, $this->userLoginID); Yii::app()->authManager->save(); } // UserProfile //$UserProfile = UserProfile::model()->findByAttributes(array('UserLoginID'=>$UserLogin->UserLoginID)); $UserProfile = UserProfile::model()->with('companies')->findByAttributes(array('UserLoginID' => $UserLogin->UserLoginID)); // echo '<pre>'; // print_r($UserProfile); // die(); // create session variables $this->setState('fullName', sprintf('%s %s', $UserProfile->FirstName, $UserProfile->LastName)); // full user name $this->setState('companyID', $UserProfile->CompanyID); // user email $this->setState('userProfileID', $UserProfile->UserProfileID); // user email $this->setState('email', $UserLogin->LoginEmail); // user email $this->setState('companyName', $UserProfile->companies->CompanyName); // user email $this->setState('agreeToTerms', $UserProfile->AgreeToTerms); // user email $this->setState('isFacilitator', $UserProfile->IsFacilitator); // user email $this->setState('UserRoleID', $UserLogin->UserRoleID); // user email } } return !$this->errorCode; }
function beforeAction($action) { Yii::app()->clientScript->registerScriptFile('/static/js/jquery-ui/i18n.min.js'); Yii::app()->clientScript->registerScriptFile('/static/js/jquery-ui/i18n/' . Yii::app()->language . '.min.js'); parent::beforeAction($action); if (Yii::app()->user->isGuest) { if (Yii::app()->controller->action->id != 'login') { $this->redirect(Yii::app()->createUrl('my/login', array('back' => urlencode(base64_encode($_SERVER['REQUEST_URI']))))); } } else { $this->myProfile = UserProfile::model()->getUserProfile(Yii::app()->user->id); } return true; }
public function actionShow($id, $mid) { Yii::app()->clientScript->registerScript('global_user_id', 'var glUserId = ' . $id . ';', CClientScript::POS_HEAD); $user = UserProfile::model()->getUserProfile($id); $myPage = Yii::app()->user->id == $id; if ($album = Albums::model()->find('user_id=:user_id AND id = :album_id', array('user_id' => $id, 'album_id' => $mid))) { $model = Photos::model(); $photos = $model->LoadLimited($mid, 0); $list = $this->renderPartial('//profile/aphotos/photos_list', array('photos' => $photos, 'user_id' => $id), true); $this->render('photos', array('model' => $model, 'profile' => $user, 'myPage' => $myPage, 'album' => $album, 'photos_count' => count($photos), 'list' => $list)); } else { echo 'Альбом не существует.'; } }
public static function getProfilePic() { $filename = Yii::app()->baseUrl . "/images/no-image.jpg"; if (isset(Yii::app()->session['login']['profImage']) && Yii::app()->session['login']['profImage'] != "") { $filename = Yii::app()->baseUrl . "/images/uploads/profileimages/" . Yii::app()->session['login']['profImage']; if (!file_exists(Yii::app()->basePath . "/../images/uploads/profileimages/" . Yii::app()->session['login']['profImage'])) { $userprofile = UserProfile::model()->findByAttributes(array('user_id' => Yii::app()->session['login']['id'])); $filename = Yii::app()->baseUrl . "/images/uploads/profileimages/" . $userprofile->profile_image; if (!file_exists(Yii::app()->basePath . "/../images/uploads/profileimages/" . $userprofile->profile_image)) { $filename = Yii::app()->baseUrl . "/images/no-image.jpg"; } } } return $filename; }
public function actionIndex() { $model = UserProfile::model()->findByPk(Yii::app()->user->id); if (isset($_POST['UserProfile'])) { $model->attributes = $_POST['UserProfile']; if ($model->validate()) { if (isset($_FILES['UserProfile']['name']['image']) && is_uploaded_file($_FILES['UserProfile']['tmp_name']['image'])) { $model->upload($_FILES['UserProfile']); } $model->save(); Yii::app()->user->setFlash('updateProfile', 'Info anda berhasil dirubah.'); } } $this->render('index', array('model' => $model)); }
public function actionIndex() { $id = Yii::app()->user->id; $model = UserProfile::model()->findByPk($id); if ($model === null) { $model = new UserProfile(); } $this->performAjaxValidation($model); if (isset($_POST['UserProfile'])) { $model->attributes = $_POST['UserProfile']; if ($model->save()) { Yii::app()->user->setFlash('profileSaved', 'Your profile Saved.'); $this->refresh(); } } $this->render('index', array('model' => $model)); }
public function actionupdatePost($message, $id) { $model = new BusinessPagePost(); $model->user_id = Yii::app()->user->userId; $model->message = $message; $model->page_id = $id; $model->date = date('Y-m-d H:i:s'); $model->save(); //Yii::app()->user->setFlash('success', "Your status has been sent posted."); //$this->redirect(Yii::app()->baseUrl . '/index.php/user/dashboard'); $Id = Yii::app()->db->getLastInsertId(); $data = BusinessPagePost::model()->findByPk($Id); $user = UserProfile::model()->findByAttributes(array('user_id' => $data['user_id'])); $array = array(); $array2 = array(); $array = $user['attributes']; $array2 = $data['attributes']; $result = array_merge($array, $array2); echo json_encode($result); }
public function actionShow($id, $mid) { $videos = new Videos(); $video = $videos->findByPk($mid); $aroundInfo = $videos->getAroundInfo($mid); $myProfile = UserProfile::model()->getUserProfile(Yii::app()->user->id); $my_videos = array(); if (Yii::app()->user->id == $id) { $myPage = true; } else { $mypage = false; $videos_on_my_page = Videos::model()->findAll(array('select' => 'file', 'condition' => 'user_id=:id', 'params' => array(':id' => Yii::app()->user->id))); foreach ($videos_on_my_page as $my_video) { $my_videos[] = $my_video['file']; } } $comments = Comments::model()->getLast('videos', $mid, 10); $comments = array_reverse($comments); $this->renderPartial('show_video', array('video' => $video, 'my_videos' => $my_videos, 'nav_link' => 'show', 'user_id' => $id, 'aroundInfo' => $aroundInfo, 'myProfile' => $myProfile, 'myPage' => $myPage, 'comments' => $comments, 'comments_tbl' => 'videos', 'comments_item_id' => $video->id)); }
public function actionDelete($aid) { if (!isset($aid) || empty($aid)) { /*тут обработать исключение*/ throw new CException('Not Found', 404); } $user_id = Yii::app()->user->id; $user = UserProfile::model()->getUserProfile($user_id); $has = UserApps::model()->count(array('condition' => 'user_id=' . $user_id . ' AND app_id=' . $aid)); if (intVal($has) < 1) { $this->redirect(Yii::app()->request->baseUrl . '/id' . Yii::app()->user->id . '/apps/my'); } $dApp = UserApps::model()->find(array('condition' => 'user_id=' . $user_id . ' AND app_id=' . $aid)); if (!$dApp->delete()) { /*тут обработать исключение*/ throw new CException('Not Found', 404); } $appDec = Apps::model()->find(array('condition' => 'id=' . $aid)); $appDec->users--; $appDec->update(); $this->redirect(Yii::app()->request->baseUrl . '/id' . Yii::app()->user->id . '/apps/my'); }
if ($item->author_id == Yii::app()->user->id || $item->owner_id == Yii::app()->user->id) { ?> <span class="control" onclick="deleteWallPost(this, '<?php echo Yii::app()->request->baseUrl; ?> /posts/delete/', <?php echo $item->id; ?> )">Удалить</span> <?php } ?> <?php $o_post = Posts::model()->findByPk($item->parent_id); if ($o_post != null) { $o_author = UserProfile::model()->getUserProfile($o_post->author_id); $textPadding = 'style="padding-left: 12px"'; ?> <div> <img style="margin-top: 4px;" src="<?php echo Yii::app()->request->baseUrl; ?> /static/css/publishedBy.gif" alt="" title="Автор оригинала" /> <a href="<?php echo Yii::app()->request->baseUrl; ?> /id<?php echo $o_author->user_id; ?> "><img width="32" style="margin-top: 4px;" src="<?php echo Yii::app()->request->baseUrl; echo $o_author->getAvatar('micro');
public function getUserProfile($userid, $share, $groupid) { $userinfo = User::model()->findByPk($userid); $profileinfo = UserProfile::model()->findByAttributes(array('user_id' => $userid)); $Criteria = new CDbCriteria(); $Criteria->condition = "userid = '" . $userid . "' and finao_activestatus != 2 and IsGroup = 1 and group_id=" . $groupid; if ($userid == Yii::app()->session['login']['id'] && $share != "share") { $Criteria->addCondition("Iscompleted = 0", "AND", "IsGroup = 0", "AND"); } if (isset($share) && $share == "share" || $userid != Yii::app()->session['login']['id']) { $Criteria->addCondition("finao_status_Ispublic = 1", "AND"); } $Criteria->order = "updateddate DESC"; $finaos = UserFinao::model()->findAll($Criteria); $latestfinao = UserFinao::model()->find(array('condition' => 'userid = ' . $userid . ' AND Iscompleted = 0 order by updateddate DESC')); if (!empty($finaos)) { $Criteria = new CDbCriteria(); $Criteria->group = 'tile_id'; $Criteria->condition = "userid = '" . $userid . "'"; $Criteria->select = "t1.tilename , t1.tile_imageurl , t1.Is_customtile, t.* "; if (!empty($finaos)) { foreach ($finaos as $finaoids) { $ids[] = $finaoids->user_finao_id; } } if (!empty($ids)) { $Criteria->addInCondition('finao_id', $ids); } $Criteria->order = 'createddate DESC'; $Criteria->join = " left join fn_tilesinfo t1 on t.tile_id = t1.tile_id and t.userid = t1.createdby "; $tilesinfo = UserFinaoTile::model()->findAll($Criteria); } else { $tilesinfo = ""; } return array('userid' => $userid, 'userinfo' => $userinfo, 'profileinfo' => $profileinfo, 'finao' => $latestfinao, 'tilesinfo' => $tilesinfo); }
<div class="search-sort padding-15pixels"> <div class="orange font-20px left">Results For <?php echo $tilename; ?> </div> <div class="search-results"> <?php $userid = Yii::app()->session['login']['id']; foreach ($userrelatedtotiles as $relatetiles) { ?> <?php $finduser = User::model()->findByAttributes(array('userid' => $relatetiles->userid)); $image = UserProfile::model()->findByAttributes(array('user_id' => $relatetiles->userid)); if ($image->profile_image != "") { $profileimage = Yii::app()->baseUrl . "/images/uploads/profileimages/" . $image->profile_image; } else { $profileimage = Yii::app()->baseUrl . "/images/no-image.jpg"; } if ($finduser->userid != Yii::app()->session['login']['id']) { if (!empty($finduser)) { $checktracktilestatus = Tracking::model()->findAllByAttributes(array('tracked_tileid' => $relatetiles->tile_id, 'tracked_userid' => $finduser->userid, 'status' => 0, 'tracker_userid' => $userid)); $checktracktile = Tracking::model()->findAllByAttributes(array('tracked_tileid' => $relatetiles->tile_id, 'tracked_userid' => $finduser->userid, 'status' => 1, 'tracker_userid' => $userid)); $counttrackers = count($checktracktile); ?> <input type="hidden" id="tileid" value="<?php echo $relatetiles->tile_id; ?> "/> <div class="results-tab">
public function actionEditBackground() { Yii::import('ext.iwi.Iwi'); $id = Yii::app()->user->id; if (!$id > 0) { throw new CException('Not Found', 404); } Yii::app()->log->routes[3]->enabled = false; if (isset($_GET['ajax'])) { $upload = Files::model()->uploadFile('avatar'); if ($upload !== false) { echo CJSON::encode(array('message' => $upload['filename'] . '.' . $upload['extension'], 'status' => 'OK')); } else { echo CJSON::encode(array('message' => 'Ошибка загрузки файла', 'status' => 'ERROR')); } exit; } if (Yii::app()->request->getPost('height') > 0) { $post = array('height' => (int) Yii::app()->request->getPost('height'), 'width' => (int) Yii::app()->request->getPost('width'), 'left' => (int) Yii::app()->request->getPost('left'), 'top' => (int) Yii::app()->request->getPost('top'), 'image' => trim(Yii::app()->request->getPost('image', ''), '/')); $filename = pathinfo($post['image'], PATHINFO_FILENAME); $path = realpath(Yii::app()->basePath . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR); $file = Files::model()->findByPk($filename); $userpath = $path . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . 'photos' . DIRECTORY_SEPARATOR; $image = new Iwi($userpath . $file->id . '.' . $file->extension); $image->resize($post['width'], $post['height']); if ($image->save($userpath . 'cover' . DIRECTORY_SEPARATOR . $file->id . '.' . $file->extension)) { $user = UserProfile::model()->find("user_id=:uid", array('uid' => $id)); $oldavatar = false; if ($user->background != $filename) { $oldavatar = $user->background; } $user->background = $filename; $user->bgposition = $post['left'] . ' ' . $post['top']; if ($user->save()) { // if($oldavatar!=false && $oldavatar != 'userTestBG.png' && is_file($userpath . $oldavatar)) // FileHelper::cleanUpload('UserProfile', $oldavatar); echo CJSON::encode(array('message' => $filename, 'status' => 'OK')); } else { echo CJSON::encode(array('message' => $user->getErrors(), 'status' => 'ERROR')); } exit; } else { //System error must be handled by administration. Yii::log("Ошибка при создании файла аватара '{$post['image']}'. Пользователь #{$id}", 'email'); echo CJSON::encode(array('status' => 'ERROR', 'message' => 'Ну удалось сохранить аватар. Попробуйте позже.')); } } //else // echo CJSON::encode(array('status'=>'ERROR','message'=>'Не хватает параметров.')); //if(isset($_GET['ajax'])) exit; //$this->render('edit_avatar'); }
public function actionPhoto($id) { $user = UserProfile::model()->getUserProfile($id); $this->renderPartial('//profile/profile/_attach_photo', array('profile' => $user)); }
public function getFriends() { $friends = UserProfile::model()->findAll(array('condition' => "t.user_id IN (SELECT friend_id FROM user_friends uf WHERE uf.user_id=:uid AND status=1)", 'params' => array(':uid' => $this->user_id))); return $friends; }
</a> </div> <div style="clear:both;"></div> <div id="tracker-<?php echo $tiledisplay->lookup_id; ?> "> <?php foreach ($gettrackercount as $getusers) { $users = User::model()->findByAttributes(array('userid' => $getusers->tracker_userid)); $userimage = UserProfile::model()->findByAttributes(array('user_id' => $getusers->tracker_userid)); ?> <div style=" color:#343434; font-size:13px; float:left; margin-left:17px;"> <a href = "<?php echo Yii::app()->createUrl('finao/motivationmesg/frndid/' . $users->userid); ?> " > <?php echo $users->profile_image; ?>
<?php echo CHtml::dropDownList('birth_month', (int) date('m', $model->birth_date), $months, array('id' => 'birth_month', 'class' => 'month')); ?> <?php echo CHtml::dropDownList('birth_year', (int) date('Y', $model->birth_date), $years, array('id' => 'birth_year', 'class' => 'year')); ?> <?php echo $form->error($model, 'birth_date'); ?> </div> <div class="field"> <?php echo $form->label($model, 'gender'); ?> <?php echo $form->dropDownList($model, 'gender', UserProfile::model()->getGenderInfo(2), array('fcselect' => true)); ?> <?php echo $form->error($model, 'gender'); ?> </div> <div class="field"> <?php echo $form->label($model, 'family'); ?> <?php echo $form->dropDownList($model, 'family', $states[$model->gender], array('fcselect' => true)); ?> <?php echo $form->error($model, 'family'); ?>
public function actionEditBackground() { Yii::import('ext.iwi.Iwi'); $id = Yii::app()->user->id; if (!$id > 0) { throw new CException('Not Found', 404); } $filev = new FileValidator(); $filev->types = array('jpg', 'jpeg', 'png', 'gif'); $filev->sizes = array('min' => 962, 250); $upload = Images::model()->uploadFile('avatar', true, $filev); if ($upload !== false && !isset($upload['error'])) { //$size = getimagesize(Yii::getPathOfAlias('webroot').'/upload/photos/'.$upload['filename'].'.'.$upload['extension']); //if($size[0]<962 || $size[1]<250){ // echo CJSON::encode(array('message'=>'Размер изображения должен быть не меньше 962 в ширине на 250 по высоте пикселей.','status'=>'ERROR')); // exit(); //} echo CJSON::encode(array('message' => $upload['filename'] . '.' . $upload['extension'], 'status' => 'OK')); } else { if (isset($upload['error'])) { echo CJSON::encode(array('message' => $upload['error'], 'status' => 'ERROR')); } } if (Yii::app()->request->getPost('height') > 0) { $post = array('height' => (int) Yii::app()->request->getPost('height'), 'width' => (int) Yii::app()->request->getPost('width'), 'left' => (int) Yii::app()->request->getPost('left'), 'top' => (int) Yii::app()->request->getPost('top'), 'image' => trim(Yii::app()->request->getPost('image', ''), '/')); $filename = basename($post['image']); $path = realpath(Yii::app()->basePath . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR); $userpath = $path . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . 'UserProfile' . DIRECTORY_SEPARATOR; $image = new Iwi($path . DIRECTORY_SEPARATOR . $post['image']); $image->resize($post['width'], $post['height'])->crop(962, 250, $post['top'], $post['left']); if ($image->save($userpath . $filename)) { $user = UserProfile::model()->find("user_id=:uid", array('uid' => $id)); $oldavatar = false; if ($user->background != $filename) { $oldavatar = $user->background; } $user->background = $filename; if ($user->save()) { if ($oldavatar != false && $oldavatar != 'userTestBG.png' && is_file($userpath . $oldavatar)) { FileHelper::cleanUpload('UserProfile', $oldavatar); } echo CJSON::encode(array('message' => $filename, 'status' => 'OK')); } else { echo CJSON::encode(array('message' => $user->getErrors(), 'status' => 'ERROR')); } exit; } else { //System error must be handled by administration. Yii::log("Ошибка при создании файла аватара '{$post['image']}'. Пользователь #{$id}", 'email'); echo CJSON::encode(array('status' => 'ERROR', 'message' => 'Ну удалось сохранить аватар. Попробуйте позже.')); } } //else // echo CJSON::encode(array('status'=>'ERROR','message'=>'Не хватает параметров.')); //if(isset($_GET['ajax'])) exit; //$this->render('edit_avatar'); }
if ($notification) { foreach ($notification as $p) { ?> <?php if ($p->type == "friend") { $senderId = $p->sender_id; $is_friend = UserFriend::model()->find('(user_id=:uid AND friend_id=:fid) AND (status = 1)', array(':uid' => $senderId, ':fid' => $p->user_id)); if ($is_friend) { $message = "is Your friend"; } else { $message = $p->message; } } $userId = $p->sender_id; $user = UserProfile::model()->findByAttributes(array('user_id' => $userId)); if (!empty($user->first_name)) { $userName = ucfirst($user->first_name) . ' ' . ucfirst($user->last_name); } else { $users = User::model()->findByPk($userId); $userName = $users['username']; } ?> <table id ="row_<?php echo $p->id; ?> " class="well-for-table" > <tr> <?php if (!empty($user->image)) { ?>
public function actionTagnote() { $finaoId = isset($_REQUEST['finao']) && is_numeric($_REQUEST['finao']) ? $_REQUEST['finao'] : null; $requestData = array('tagnoteId' => $finaoId); $client = new SoapClient('http://' . $_SERVER['SERVER_NAME'] . '/shop/api/soap/?wsdl'); $sessionId = $client->login('apiintegrator', 'ap11ntegrator'); $tagnoteResponse = $client->call($sessionId, 'finao.info', array($requestData)); $user = User::model()->findAllByAttributes(array('mageid' => $tagnoteResponse['customerId'])); $userimage = UserProfile::model()->findAllByAttributes(array('user_id' => $user[0]['userid'])); $this->renderPartial('_tagnote', array('tagnote' => isset($tagnoteResponse['finao']) ? $tagnoteResponse['finao'] : '', 'user' => $user, 'userimage' => $userimage)); }