コード例 #1
0
ファイル: User.php プロジェクト: austinvernsonger/casebox
 /**
  * get email folder id for specified user id. If folder does not exist it is created automaticly.
  * @param  int $user_id
  * @return int email folder id
  */
 public static function getEmailFolderId($user_id = false)
 {
     $rez = null;
     if (empty($user_id)) {
         $user_id = $_SESSION['user']['id'];
     }
     $pid = User::getUserHomeFolderId($user_id);
     $res = DB\dbQuery('SELECT id
         FROM tree
         WHERE user_id = $1
             AND SYSTEM = 1
             AND pid =$2
             AND type = 1', array($_SESSION['user']['id'], $pid)) or die(DB\dbQueryError());
     if ($r = $res->fetch_assoc()) {
         $rez = $r['id'];
     }
     $res->close();
     if (empty($rez)) {
         DB\dbQuery('INSERT INTO tree (
                 pid
                 ,user_id
                 ,`system`
                 ,`type`
                 ,`name`
                 ,cid
                 ,uid
                 ,template_id)
             VALUES (
                 $1
                 ,$2
                 ,1
                 ,1
                 ,\'[Emails]\'
                 ,$3
                 ,$3
                 ,$4)', array($pid, $user_id, $_SESSION['user']['id'], Config::get('default_folder_template'))) or die(DB\dbQueryError());
         $rez = DB\dbLastInsertId();
         Solr\Client::runCron();
     }
     return $rez;
 }