PHP Method User::findById, codiad Code Examples

This page contains top rated real world PHP examples of method User::findById from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: AdminUsersController.php Project: christiannwamba/laravel-site
0
 public function printDetail($id)
 {
     $user = $this->userRepository->findById($id);
     $pdf = PDF::loadView('admin.users.detail', compact('user'));
     return $pdf->setPaper('a4')->setOrientation('landscape')->setWarnings(false)->stream(str_random(10) . '.pdf');
     //        return View::make('admin.users.detail',compact('user'));
 }
Example #2
Show file File: ReportController.php Project: mpetcu/lime-juice
0
 /**
  * Show files generated by reports This action will be viewed by
  */
 public function indexAction()
 {
     $user = User::findById($this->session->get("user-data")->getId());
     if ($this->request->get('id')) {
         $db = Db::findById($this->request->get('id'));
         $user->setConfig('db', $db->getId());
     }
     if ($user->getConfig('db')) {
         $db = isset($db) ? $db : Db::findById($user->getConfig('db'));
         if (!$this->request->get('id')) {
             return $this->response->redirect('report/index?id=' . $db->getId());
         }
         if (!$this->getUserSession()->hasPermission($db, 'view')) {
             return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'error404'));
         } else {
             $this->view->dbm = $db;
             $this->view->currentDbId = $db->getId();
         }
     } else {
         return $this->response->redirect('report/default');
     }
     //if master show users
     if ($this->getUserRole() == 'master') {
         $this->view->users = User::find(['conditions' => ['type' => 'operator', 'status' => 1]]);
     }
 }
Example #3
Show file File: UsersController.php Project: ale88andr/Nova
0
 public function update()
 {
     $user = User::findById(1);
     $user->permit(['email']);
     $user->email = 'ale88andr@inbox.ru';
     $user->login = 'blah';
     $user->update();
 }
Example #4
Show file File: users_controller.php Project: johnulist/ecommerce
0
 function admin_view_user($id = null)
 {
     if (!$id) {
         $this->Session->setFlash('Wrong user ID!');
     } else {
         $user = $this->User->findById($id);
         $this->set(compact('user'));
     }
 }
Example #5
Show file File: CommonHelper.php Project: agashish/test_new
0
 public function getFirstLastName($userData = null)
 {
     App::import("Model", "User");
     $userObject = new User();
     /* Get data from id */
     $getUserData = $userObject->findById($userData);
     /* Get Data */
     $lastName = str_split($getUserData['User']['last_name']);
     return ucfirst($getUserData['User']['first_name'] . ' ' . $lastName[0]);
 }
Example #6
Show file File: user.php Project: jankvak/Schedule-of-pain
0
 function home()
 {
     $user = new User();
     $usr = $user->findById($this->session->read('uid'));
     $this->set('name', $this->session->read('name'));
     $this->set('mail', $usr["mail"]);
     $calendar = new Calendar();
     $actualEvents = $calendar->getActualEvents();
     $futureEvents = $calendar->getFutureEvents();
     $this->set('actualEvents', $actualEvents);
     $this->set('futureEvents', $futureEvents);
 }
Example #7
Show file File: notificator.php Project: jankvak/Schedule-of-pain
0
 public function sendCourseAssignedMsg($requirements)
 {
     $user = new User();
     $garant = $this->controller->session->read("name");
     $pract = $user->findById($requirements->cviciaci);
     $teacher = $user->findById($requirements->prednasajuci);
     $list = array(1 => array("mail" => $pract["mail"], "role" => "Cvičiaci", "url_part" => "/pract/requirements/edit/"), 2 => array("mail" => $teacher["mail"], "role" => "Prednášajúci", "url_part" => "/teacher/requirements/edit/"));
     for ($i = 1; $i < 3; $i++) {
         $mail = $list[$i]["mail"];
         $toList = array($mail);
         $toList = $this->__filterList($toList);
         if (empty($toList)) {
             continue;
         }
         $default = array('DATE' => date("d.m.Y H:i", time()), 'GARANT' => $garant, 'COURSE' => Subjects::getSubjectInfo($requirements->id), 'ROLE' => $list[$i]["role"], 'URL' => BASE_URL . $list[$i]["url_part"] . $requirements->id);
         $message = $this->__createTemplate("messages/courseAssigned.tpl", $default);
         $subject = "[" . Subjects::getSubjectInfo($requirements->id) . "]" . " - priradená zodpovednosť " . $list[$i]["role"];
         $ref = $this->__createRef("garant.course", $requirements->id);
         $this->sendNotifyMessage($toList, $message, $subject, $ref);
     }
 }
Example #8
Show file File: UserController.php Project: mpetcu/lime-juice
0
 /**
  * Change pass from a master user account
  * @return mixed
  */
 public function passAction()
 {
     if ($this->securePage(true)) {
         $userSess = $this->session->get("user-data");
         $user = User::findById($userSess->getId());
         if ($this->processForm($user, 'PassForm')) {
             $this->flash->success("Your account password was succesfully changed.");
             return $this->response->redirect('user/edit');
         }
         $this->view->user = $user;
     }
 }
Example #9
Show file File: App.php Project: ArtemRochev/MVC-Framework
0
 public static function isAdmin()
 {
     if (isset($_COOKIE['token']) && isset($_COOKIE['user_id'])) {
         $user = User::findById($_COOKIE['user_id']);
         //var_dump('User: (' . $user->token . ')');
         //var_dump($_COOKIE['token']);
         //var_dump($user->token);
         if ($_COOKIE['token'] == $user->token && $user->is_admin) {
             return true;
         }
     }
     return false;
 }
Example #10
Show file File: CalendarEvent.php Project: jacekciach/wolfcms-calendar-plugin
0
 public function getAuthor()
 {
     if (empty($this->created_by_id)) {
         return null;
     } else {
         $user = User::findById($this->created_by_id);
         if ($user instanceof User) {
             return $user->name;
         } else {
             return null;
         }
     }
 }
Example #11
Show file File: UserController.php Project: edderrd/Aerocal
0
 public function editAction()
 {
     $id = $this->_request->getParam("id");
     $data = User::findById($id);
     $userAircrafts = App_Utils::toList($data['Aircraft'], "id", "id");
     $form = new Form_UserEdit();
     $form->role_id->addMultiOptions(App_Utils::toList(AclRole::findAll(), 'id', 'name'));
     $form->aircraft->setMultiOptions(App_Utils::toList($data['Aircraft'], 'id', 'name'));
     $form->aircraft_available->setMultiOptions(App_Utils::toList(Aircraft::findAll(array('exclude' => $userAircrafts)), 'id', 'name'));
     $form->role_id->setValue($data['role_id']);
     $form->user_id->setValue($id);
     $form->populate($data);
     $options = array('title' => "Edit User", 'url' => "/user/edit/format/json/subaction/submit", 'button' => "Edit", 'success' => array("button" => array("title" => "Close", "action" => "close"), "redirect" => "/user/list", "message" => "User {$form->first_name->getValue()} {$form->last_name->getValue()} modified correctly"), 'model' => array("class" => "User", "method" => "edit"));
     $this->ajaxFormProcessor($form, $options);
 }
Example #12
Show file File: KickCampaign.php Project: bklam/1eq_sample
0
 public static function checkAndAssignKickCampaignToUser($userId)
 {
     Log::user("checkAndAssignKickCampaignToUser");
     $currentWeek = OBCampaign::getCurrentWeek($userId);
     Log::user("current week is {$currentWeek}");
     $lala = Campaign::doesUserHaveCampaign($userId, Campaign::$_KICK_TRACKER_CAMPAIGN);
     Log::user("does this person already have this campaign? {$lala}");
     $conditional = OBCampaign::getCurrentWeek($userId) >= 28 && !Campaign::doesUserHaveCampaign($userId, Campaign::$_KICK_TRACKER_CAMPAIGN);
     $currentUser = User::findById($userId);
     $hasLocation = $currentUser->location;
     boldError("the conditional is: {$conditional}");
     if (OBCampaign::getCurrentWeek($userId) >= 28 && $hasLocation) {
         Campaign::assignCampaignToUser(Campaign::$_KICK_TRACKER_CAMPAIGN, $userId);
         Action::assignActionItem($userId, KickCampaign::$_KICK_TRACKER_ACTION_ID);
         boldError("ASSIGNED KICK CAMPAIGN");
     }
 }
Example #13
Show file File: AppController.php Project: a0108393/cms-system
0
 public function beforeFilter()
 {
     //check isset user logged update info
     if ($this->Auth->loggedIn()) {
         App::import('Model', 'User');
         $user = new User();
         $this->Session->write('Auth', $user->findById($this->Auth->User('id')));
     }
     //load setting
     $this->loadModel('Settings');
     $settings = $this->Settings->find('all');
     $configs = array();
     foreach ($settings as $key => $row) {
         $configs[$row['Settings']['category']][$row['Settings']['param_name']] = $row['Settings']['param_value'];
     }
     Configure::write('Settings', $configs);
     //set limit for paginate
     if (isset($this->request->query['limit'])) {
         $this->paginate['limit'] = $this->request->query['limit'];
     }
     //setting the timezone for all dates using TimeHelper
     if ($this->Session->read('Auth.User.timezone')) {
         Configure::write('Config.timezone', $this->Session->read('Auth.User.timezone'));
     }
     if ($this->name == 'Users') {
         $this->Auth->allow('forgot', 'captcha');
     }
     if ($this->name == 'Enquiries') {
         $this->Auth->allow('add_client');
     }
     if ($this->name == 'AdvertisingLinks') {
         $this->Auth->allow('go');
     }
     if ($this->name == 'Briefs') {
         $this->Auth->allow('visitor');
     }
     $this->Auth->loginAction = Configure::read('Core.LoginAction');
     $this->Auth->loginRedirect = Configure::read('Core.LoginRedirect');
     $this->Auth->logoutRedirect = Configure::read('Core.LogoutRedirect');
     // prd($this->name);
     if (!$this->Permissionable->checkModuleAccess($this) && $this->name != 'ToolbarAccess') {
         die('denny');
     }
 }
Example #14
Show file File: Call.php Project: atduarte/allsos
0
 public function providerRejects($id)
 {
     if ($this->isClosed()) {
         return false;
     }
     $key = array_search($id, $this->providers);
     if ($key !== false) {
         unset($this->providers[$key]);
         if (!$this->save()) {
             return false;
         }
         if (count($this->providers) == 0) {
             $user = User::findById((string) $this->user);
             Push::send('Não foram encontradas pessoas disponíveis.', [$user->registrationId]);
         }
         return true;
     }
     return false;
 }
Example #15
Show file File: Auth.php Project: exonintrendo/Primer
0
 /**
  * Logs user in if cookie value matches database value
  *
  * @return bool
  */
 public function loginWithCookie()
 {
     $cookie = isset($_COOKIE['rememberme']) ? $_COOKIE['rememberme'] : '';
     if ($cookie) {
         list($user_id, $token, $hash) = explode(':', base64_decode($cookie));
         if ($hash !== hash('sha256', $user_id . ':' . $token)) {
             return false;
         }
         // do not log in when token is empty
         if (empty($token)) {
             return false;
         }
         // @TODO: need to find a better way to tie this in without using global User
         $user = \User::findById($user_id);
         if ($user->rememberme_token == $token) {
             $this->login($user);
             return true;
         } else {
             $this->_response->setCookie(Cookie::create()->make('rememberme', false, time() - 3600 * 3650, '/'));
             $this->logout();
         }
     }
     return false;
 }
Example #16
Show file File: handle.php Project: jinghuizhai/weixin
0
function findUserById()
{
    header('Content-type: application/json');
    if (getvar('admin', 'session')) {
        $user_id = getvar('user_id', 'post');
        if (!empty($user_id)) {
            $user = new User();
            $result = $user->findById((int) $user_id);
            if ($result) {
                echo json_encode($result);
            } else {
                echo '没有查询出正确的结果';
            }
        }
    } else {
        echo '请先登录';
    }
}
Example #17
Show file File: index.php Project: mmaydin/peak
0
<?php

include 'require.php';
if (!(isset($_SESSION['user_id']) && !empty($_SESSION['user_id']))) {
    header('location:login.php');
    exit;
}
$user = User::findById($_SESSION['user_id']);
$topUsers = Statistics::getTopList();
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Peak Games Test Page</title>
        <meta charset="UTF-8">

        <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">

        <script src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
        <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

        <script>
            $(function() {
                $("#tab-menu").tabs();
            });
        </script>
    </head>
    <body>

        <div id="tab-menu">
            <ul>
Example #18
Show file File: profilectrl.php Project: samdubey/ads2
0
 public static function change_password()
 {
     return function ($request, $response) {
         $id = $request->session('id');
         if ($id) {
             $user = User::findById($id);
             $data = $request->data();
             $auth = $user->validate($data->password);
             if ($auth) {
                 $user->password = $data->new_password;
                 $user->save();
                 $response->code(200);
             } else {
                 $response->code(403);
             }
         } else {
             $response->code(404);
         }
     };
 }
Example #19
Show file File: adminuser.php Project: xxxkikixxx/sti_projet_2
0
                }
                if ($formValid) {
                    try {
                        User::create($email, $pwd, $right, $actif);
                    } catch (Exception $e) {
                        $formValid = false;
                        $errors["other"] = $e->getMessage();
                    }
                }
            }
        } else {
            if (isset($get)) {
                if (Tools::isStringValid($get) && isDetail($get)) {
                    $type = $get;
                    $id = Tools::prepareUserArgInteger($_GET["id"]);
                    $usr = User::findById($id);
                    if ($usr == null) {
                        $errors["id"] = "The user " . $id . " doesn't exist.";
                    }
                }
            }
        }
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
<title>STI 2</title>
	<?php 
Example #20
Show file File: BaseUser.php Project: nic162/Zend-Framework-Skeleton
0
 /**
  * Reload the data of the user in the session
  *
  * @return void
  */
 public static function reloadSession()
 {
     $auth = Zend_Auth::getInstance();
     switch (CURRENT_MODULE) {
         case 'frontend':
             $userModel = new User();
             $user = $userModel->findById(self::getSession()->id);
             $user->get('group');
             break;
         case 'backoffice':
             $userModel = new BackofficeUser();
             $user = $userModel->findById(self::getSession()->id);
             $user->groups = $user->findManyToManyRowset('Group', 'BackofficeUserGroup');
             $user->group = $user->groups[0];
             break;
     }
     $session = new stdClass();
     foreach ($user as $k => $v) {
         $session->{$k} = $v;
     }
     $session->group->name = $user->get('group')->name;
     $auth->getStorage()->write($session);
 }
Example #21
Show file File: UserController.php Project: albertobraschi/toad
0
 function delete($id)
 {
     if (!AuthUser::hasPermission('administrator')) {
         Flash::set('error', __('You do not have permission to access the requested page!'));
         redirect(get_url());
     }
     // security (dont delete the first admin)
     if ($id > 1) {
         // find the user to delete
         if ($user = User::findById($id)) {
             if ($user->delete()) {
                 Flash::set('success', __('User <strong>:name</strong> has been deleted!', array(':name' => $user->name)));
             } else {
                 Flash::set('error', __('User <strong>:name</strong> has not been deleted!', array(':name' => $user->name)));
             }
         } else {
             Flash::set('error', __('User not found!'));
         }
     } else {
         Flash::set('error', __('Action disabled!'));
     }
     redirect(get_url('user'));
 }
Example #22
Show file File: edit.php Project: sochea09/pdo-smarty
0
        $data['usr_id'] = $id;
        isset($_POST['username']) ? $data['usr_name'] = $_POST['username'] : '';
        isset($_POST['password']) ? $data['usr_password'] = $_POST['password'] : '';
        isset($_POST['email']) ? $data['usr_email'] = $_POST['email'] : '';
        isset($_POST['roles']) ? $data['rol_id'] = $_POST['roles'] : '';
        $user = new User();
        $stmt = $user->postUpdateUser($data);
        if ($stmt) {
            //header('location:/user/default.html');
            header('location:index.php?module=user&action=default');
        } else {
            redirectBack();
        }
    }
}
if ($id) {
    $user = new User();
    $result = $user->findById($id);
    if ($result) {
        $smarty->assign('data', $result);
    } else {
        redirectBack();
    }
}
$role = new Role();
$rol_list = $role->listRoles();
foreach ($rol_list as $ro) {
    $roles[$ro['rol_id']] = $ro['rol_desc'];
}
$smarty->assign('roles', $roles);
$smarty->display(VIEW . 'edit.tpl');
Example #23
Show file File: Layout.php Project: albertobraschi/toad
0
 public function creator()
 {
     return User::findById($this->createdById());
 }
Example #24
Show file File: edit_user.php Project: ALCHEMIST09/one-square-foot
0
}
$permissions = array('admin');
try {
    $ac->checkPermissions($permissions);
} catch (Exception $e) {
    $mesg = $e->getMessage();
    $session->message($mesg);
    redirect_to($_SERVER['HTTP_REFERER']);
}
if (isset($_GET['uid']) && !empty($_GET['uid'])) {
    $user_id = (int) $_GET['uid'];
    if (!is_int($user_id)) {
        $session->message("User edit failed. An invalid value was sent throught the URL");
        redirect_to("view_users.php");
    } else {
        $user = User::findById($user_id);
    }
}
/////////////////////////////////////////////////////////////////
///////////////////////// PROCESS SUBMIT ////////////////////////
/////////////////////////////////////////////////////////////////
if (isset($_POST['submit'])) {
    $fname = $_POST['fname'];
    $lname = $_POST['lname'];
    $username = $_POST['username'];
    $password = $_POST['passwd'];
    if (empty($fname) || empty($lname) || empty($username) || empty($password)) {
        $err = "Form fields marked with an asterix are required";
    } else {
        $user->setFirstName($fname);
        $user->setLastName($lname);
Example #25
Show file File: class.ArrearsPaid.php Project: ALCHEMIST09/one-square-foot
0
 /**
  * Set the application user receiving the rent payment
  * @param object $sessionObj A session object
  */
 public function setReceivingAgent(Session $sessionObj)
 {
     $user = User::findById($sessionObj->userID);
     $this->_agent = $user->getFullName();
 }
Example #26
Show file File: fetchWishlistData.php Project: hanleychan/expenses
0
<?php

$user = User::findById($session->userID);
// fetch all wishlist items if not displaying data for a group, a single item or adding an item
if (!isset($_GET["item"]) && !isset($_GET["group"]) && !isset($_GET["addItem"])) {
    $showAllItems = true;
    // determine display order
    if (isset($_GET["sortBy"])) {
        if (trim(strtolower($_GET["sortBy"])) === "item") {
            $sortBy = "item";
        } else {
            if (trim(strtolower($_GET["sortBy"])) === "price") {
                $sortBy = "price";
            } else {
                if (trim(strtolower($_GET["sortBy"])) === "group") {
                    $sortBy = "groupName";
                } else {
                    $sortBy = "id";
                }
            }
        }
    } else {
        $sortBy = "id";
    }
    if (isset($_GET["sortOrder"])) {
        if (trim(strtolower($_GET["sortOrder"])) === "asc") {
            $sortOrder = "asc";
        } else {
            $sortOrder = "desc";
        }
    } else {
Example #27
Show file File: ApprovalModelEventListener.php Project: hiniarata/Approval
0
 /**
  * 申請・承認・差戻し連絡メール送信
  *
  * @param   array $setting
  * @param   array   $approvalData
  * @param   array   $postData
  * @param   array   $approvalType
  * @return  boolean
  * @access  public
  */
 private function _sendApprovalMail($setting, $approvalData = null, $postData, $approvalType)
 {
     /* インポート */
     //コンポーネント
     /* TODO メール送信にBcEmailComponentを使用する
        App::import('Component', 'BcEmail');
        */
     //モデル
     App::import('Model', 'User');
     $userModel = new User();
     //サイト設定
     App::import('Model', 'SiteConfig');
     $siteConfigModel = new SiteConfig();
     $siteConfigs = $siteConfigModel->find('first', array('conditions' => array('SiteConfig.name' => 'email')));
     /* 情報の整理 */
     //タイプ
     $type = $setting['ApprovalLevelSetting']['type'];
     //------------------------------
     // 固定ページ
     //------------------------------
     if ($type == 'page') {
         //承認タイプによって内容を変更する
         switch ($approvalType) {
             case 1:
                 $approvalTypeVal = '承認申請';
                 $firstMes = '表題の固定ページについて、前段階の承認権限者より承認が下りました。' . "\n";
                 $firstMes .= '内容をお確かめのうえ、承認処理をお願いします。' . "\n" . "\n";
                 break;
             case 2:
                 $approvalTypeVal = '差戻通知';
                 $firstMes = '表題の固定ページについて、次段階の承認権限者より差戻しがありました。' . "\n";
                 $firstMes .= '内容をお確かめのうえ、承認処理をお願いします。' . "\n" . "\n";
                 break;
             case 3:
                 $approvalTypeVal = '承認申請';
                 $firstMes = '表題の固定ページについて、作成者より承認申請がありました。' . "\n";
                 $firstMes .= '内容をお確かめのうえ、承認処理をお願いします。' . "\n" . "\n";
                 break;
             default:
                 break;
         }
         //メールを送るべき相手の段階
         if (!empty($approvalData)) {
             //ただし差戻し後の申請段階だとpass_stageが0になっている。
             //申請時のメールは常に第1段階に権限者へ渡る。
             if ($approvalType == 3) {
                 $passStage = 1;
             } else {
                 $passStage = $approvalData['ApprovalPage']['pass_stage'];
             }
             //新規作成時は1段目の権限者に送る。
         } else {
             $passStage = 1;
         }
         //タイトルの確認
         $title = $postData['Page']['title'];
         //送信先のタイプ
         if ($passStage != 0) {
             //最初の段階でなければgroupかuserかを取得
             $approverType = $setting['ApprovalLevelSetting']['level' . $passStage . '_type'];
         } else {
             $approverType = 'user';
             //最初の段階まで戻っていれば作成者(user)にメールする。
         }
         //最初の申請前の段階まで戻った時は作成者に送る
         //そうでなければ権限者に送る。
         if ($approvalData['ApprovalPage']['next_approver_id'] != 0) {
             //送信先のユーザーを特定する。
             if ($approverType == 'user') {
                 //ユーザーID
                 $userID = $setting['ApprovalLevelSetting']['level' . $passStage . '_approver_id'];
                 //ユーザー情報の取得
                 $userData = $userModel->findById($userID);
             } else {
                 //グループID
                 $groupID = $setting['ApprovalLevelSetting']['level' . $passStage . '_approver_id'];
                 $userDatas = $userModel->find('all', array('conditions' => array('User.user_group_id' => $groupID)));
             }
             //申請の前まで戻ってしまった場合。
         } else {
             $userID = $postData['Page']['author_id'];
             $userData = $userModel->findById($userID);
         }
         //メッセージの取得
         $mailData['message'] = '';
         if (!empty($postData['Approval']['approval_comment'])) {
             $mailData['message'] = $postData['Approval']['approval_comment'];
         }
         /* メール送信設定 */
         // TODO BcEmailComponentを使って送信する。
         mb_language("japanese");
         mb_internal_encoding("UTF-8");
         $subject = "【" . $approvalTypeVal . "】" . $title;
         $from = $siteConfigs['SiteConfig']['value'];
         //メールの内容作成
         $body = $firstMes . "■申し送り事項" . "\n" . $mailData['message'] . "\n" . "\n" . "以上";
         //送信処理
         if ($approverType == 'user') {
             if (!empty($userData['User']['email'])) {
                 //メールの送信処理実行
                 $to = $userData['User']['email'];
                 mb_send_mail($to, $subject, $body, "From:" . $from);
             }
             //グループだったら全員にループしつつメールする。
         } elseif ($approverType == 'group') {
             if (!empty($userDatas)) {
                 foreach ($userDatas as $data) {
                     if (!empty($data['User']['email'])) {
                         //メールの送信処理実行
                         $to = $userData['User']['email'];
                         mb_send_mail($to, $subject, $body, "From:" . $from);
                     }
                 }
             }
         }
         //------------------------------
         // ブログ
         //------------------------------
     } else {
         //承認タイプによって内容を変更する
         switch ($approvalType) {
             case 1:
                 $approvalTypeVal = '承認申請';
                 $firstMes = '表題のブログ記事について、前段階の承認権限者より承認が下りました。' . "\n";
                 $firstMes .= '内容をお確かめのうえ、承認処理をお願いします。' . "\n" . "\n";
                 break;
             case 2:
                 $approvalTypeVal = '差戻通知';
                 $firstMes = '表題のブログ記事について、次段階の承認権限者より差戻しがありました。' . "\n";
                 $firstMes .= '内容をお確かめのうえ、承認処理をお願いします。' . "\n" . "\n";
                 break;
             case 3:
                 $approvalTypeVal = '承認申請';
                 $firstMes = '表題のブログ記事について、作成者より承認申請がありました。' . "\n";
                 $firstMes .= '内容をお確かめのうえ、承認処理をお願いします。' . "\n" . "\n";
                 break;
             default:
                 break;
         }
         //メールを送るべき相手の段階(0の時は作成者に送ることになる)
         if (!empty($approvalData)) {
             //ただし差戻し後の申請段階だとpass_stageが0になっている。
             //申請時のメールは常に第1段階に権限者へ渡る。
             if ($approvalType == 3) {
                 $passStage = 1;
             } else {
                 $passStage = $approvalData['ApprovalPost']['pass_stage'];
             }
             //新規作成時は1段目の権限者に送る。
         } else {
             $passStage = 1;
         }
         //タイトルの確認
         $title = $postData['BlogPost']['name'];
         //送信先のタイプ
         if ($passStage != 0) {
             //最初の段階でなければgroupかuserかを取得
             $approverType = $setting['ApprovalLevelSetting']['level' . $passStage . '_type'];
         } else {
             $approverType = 'user';
             //最初の段階まで戻っていれば作成者(user)にメールする。
         }
         //echo $passStage;exit();
         //申請の前段階まで戻った場合は作成者にメールする。
         //そうでなければ、権限者へメールする。
         if ($approvalData['ApprovalPost']['next_approver_id'] != 0) {
             //送信先のユーザーを特定する。
             if ($approverType == 'user') {
                 //ユーザーID
                 $userID = $setting['ApprovalLevelSetting']['level' . $passStage . '_approver_id'];
                 //ユーザー情報の取得
                 $userData = $userModel->findById($userID);
             } else {
                 //グループID
                 $groupID = $setting['ApprovalLevelSetting']['level' . $passStage . '_approver_id'];
                 $userDatas = $userModel->find('all', array('conditions' => array('User.user_group_id' => $groupID)));
             }
             //申請の前段階まで戻ってしまった
         } else {
             $userID = $postData['BlogPost']['user_id'];
             $userData = $userModel->findById($userID);
         }
         //メッセージの取得
         $mailData['message'] = '';
         if (!empty($postData['Approval']['approval_comment'])) {
             $mailData['message'] = $postData['Approval']['approval_comment'];
         }
         /* メール送信設定 */
         // TODO BcEmailComponentを使って送信する。
         mb_language("japanese");
         mb_internal_encoding("UTF-8");
         $subject = "【" . $approvalTypeVal . "】" . $title;
         $from = $siteConfigs['SiteConfig']['value'];
         //メールの内容作成
         $body = $firstMes . "■申し送り事項" . "\n" . $mailData['message'] . "\n" . "\n" . "以上";
         //送信処理
         if ($approverType == 'user') {
             if (!empty($userData['User']['email'])) {
                 //メールの送信処理実行
                 $to = $userData['User']['email'];
                 mb_send_mail($to, $subject, $body, "From:" . $from);
             }
             //グループだったら全員にループしつつメールする。
         } elseif ($approverType == 'group') {
             if (!empty($userDatas)) {
                 foreach ($userDatas as $data) {
                     if (!empty($data['User']['email'])) {
                         //メールの送信処理実行
                         $to = $userData['User']['email'];
                         mb_send_mail($to, $subject, $body, "From:" . $from);
                     }
                 }
             }
         }
     }
 }
Example #28
Show file File: class.Logger.php Project: ALCHEMIST09/one-square-foot
0
 /**
  * Magic __construct
  * Set to private to limit instantiation to only
  * one instance, thus save system resources while logging
  */
 private function __construct()
 {
     global $session;
     $this->user = User::findById($session->userID)->getFullName();
 }
Example #29
Show file File: ModelWriteTest.php Project: manzapanza/cakephp-api-utils
0
 /**
  * testUpdateExisting method
  *
  * @return void
  */
 public function testUpdateExisting()
 {
     $this->loadFixtures('User', 'Article', 'Comment');
     $TestModel = new User();
     $TestModel->create();
     $TestModel->save(array('User' => array('user' => 'some user', 'password' => 'some password')));
     $this->assertTrue(is_int($TestModel->id) || intval($TestModel->id) === 5);
     $id = $TestModel->id;
     $TestModel->save(array('User' => array('user' => 'updated user')));
     $this->assertEquals($id, $TestModel->id);
     $result = $TestModel->findById($id);
     $this->assertEquals('updated user', $result['User']['user']);
     $this->assertEquals('some password', $result['User']['password']);
     $Article = new Article();
     $Comment = new Comment();
     $data = array('Comment' => array('id' => 1, 'comment' => 'First Comment for First Article'), 'Article' => array('id' => 2, 'title' => 'Second Article'));
     $result = $Article->save($data);
     $this->assertFalse(empty($result));
     $result = $Comment->save($data);
     $this->assertFalse(empty($result));
 }
Example #30
Show file File: UserController.php Project: ReekenX/wolfcms
0
 public function edit($id)
 {
     if (AuthUser::getId() != $id && !AuthUser::hasPermission('user_edit')) {
         Flash::set('error', __('You do not have permission to access the requested page!'));
         redirect(get_url());
     }
     // check if trying to save
     if (get_request_method() == 'POST') {
         return $this->_edit($id);
     }
     if ($user = User::findById($id)) {
         $this->display('user/edit', array('action' => 'edit', 'csrf_token' => SecureToken::generateToken(BASE_URL . 'user/edit'), 'user' => $user, 'permissions' => Record::findAllFrom('Role')));
     } else {
         Flash::set('error', __('User not found!'));
     }
     redirect(get_url('user'));
 }