protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $this->conn = $databaseManager->getDatabase('doctrine')->getDoctrineConnection(); $sql = 'SELECT id FROM member WHERE is_active != 0'; $where = array(); if ( $options['min'] && $options['max'] && $options['min'] <= $options['max']) { $sql .= ' AND id BETWEEN ? AND ?'; $where = array(intval($options['min']),intval($options['max'])); } $memberIds = $this->conn->fetchColumn($sql, $where); $this->setContents(); foreach ($memberIds as $memberid) { $randomtime = $this->makeRandomTime($options['date'],$options['number']); for ($i=0; $i<$options['number']; ++$i) { $title=$this->makeRandomContents('title',$options['titlecount']); $body=$this->makeRandomContents('body',$options['bodycount']); $diary = new Diary(); $diary->setMemberId($memberid); $diary->setTitle($title); $diary->setBody($body); $diary->setPublicFlag(1); $diary->setCreatedAt($randomtime[$i]); $diary->setUpdatedAt($randomtime[$i]); $diary->save(); $diary->free(); $this->logSection('posted a diary', sprintf('%s %s', $memberid, $randomtime[$i])); } } }
public function executePost(sfWebRequest $request) { $this->forward400If('' === (string) $request['title'], 'title parameter is not specified.'); $this->forward400If('' === (string) $request['body'], 'body parameter is not specified.'); $this->forward400If(!isset($request['public_flag']) || '' === (string) $request['public_flag'], 'public flag is not specified'); if (isset($request['id']) && '' !== $request['id']) { $diary = Doctrine::getTable('Diary')->findOneById($request['id']); $this->forward400If(false === $diary, 'the specified diary does not exit.'); $this->forward400If(false === $diary->isAuthor($this->member->getId()), 'this diary is not yours.'); } else { $diary = new Diary(); $diary->setMemberId($this->member->getId()); } $diary->setTitle($request['title']); $diary->setBody($request['body']); $diary->setPublicFlag($request['public_flag']); $diary->save(); $this->diary = $diary; for ($i = 1; $i <= 3; $i++) { $diaryImage = Doctrine::getTable('DiaryImage')->retrieveByDiaryIdAndNumber($diary->getId(), $i); $filename = basename($_FILES['diary_photo_' . $i]['name']); if (!is_null($filename) && '' !== $filename) { try { $validator = new opValidatorImageFile(array('required' => false)); $validFile = $validator->clean($_FILES['diary_photo_' . $i]); } catch (Exception $e) { $this->forward400($e->getMessage()); } $f = new File(); $f->setFromValidatedFile($validFile); $f->setName(hash('md5', uniqid((string) $i) . $filename)); if ($stream = fopen($_FILES['diary_photo_' . $i]['tmp_name'], 'r')) { if (!is_null($diaryImage)) { $diaryImage->delete(); } $bin = new FileBin(); $bin->setBin(stream_get_contents($stream)); $f->setFileBin($bin); $f->save(); $di = new DiaryImage(); $di->setDiaryId($diary->getId()); $di->setFileId($f->getId()); $di->setNumber($i); $di->save(); $diary->updateHasImages(); } else { $this->forward400(__('Failed to write file to disk.')); } } $deleteCheck = $request['diary_photo_' . $i . '_photo_delete']; if ('on' === $deleteCheck && !is_null($diaryImage)) { $diaryImage->delete(); } } }
protected function renderReview($time) { $uid = $this->getUid(); $data = array("total" => Diary::model()->countDiaryTotalByUid($uid, $time["start"], $time["end"]), "unreviews" => Diary::model()->countUnReviewByUids($uid, $time["start"], $time["end"])); $data["reviewrate"] = $this->calcReviewRate($data["unreviews"], $data["total"]); $this->render(self::REVIEW, $data); }
public function actionIndex() { $criteria = new CDbCriteria(); // 创建CDbCriteria对象 $criteria->condition = "(style & 2) !=0"; // 设置查询条件 $cheap = Route::model()->findAll($criteria); $criteria->condition = '(style&4) !=0'; $hot = Route::model()->findAll($criteria); $area = Area::model()->findAll(); $criteria1 = new CDbCriteria(); // 创建CDbCriteria对象 $criteria1->select = "title"; // 设置查询条件 $criteria1->limit = 8; $diary = Diary::model()->findAll($criteria1); $continent = Continent::model()->findAll(); $boat = Boat::model()->findAll(); //var_dump($continent); $this->g_area = $area; $this->g_continent = $continent; $this->g_company = Company::model()->findAll(); $year = date("Y"); $month = date('n'); $arr = array(); for ($i = $month; $i <= 12; $i++) { array_push($arr, $year . '年' . $i . '月'); } $year += 1; for ($i = 1; $i <= 12; $i++) { array_push($arr, $year . '年' . $i . '月'); } $this->g_data = $arr; $this->render('index', array('hot' => $hot, 'cheap' => $cheap, 'area' => $area, 'diary' => $diary, 'continent' => $continent, 'boat' => $boat)); }
public function countScoreByUid($uid, $start, $end) { $criteria = array("select" => "diaryid", "condition" => sprintf("uid = %d AND addtime BETWEEN %d AND %d", $uid, $start, $end)); $res = Diary::model()->fetchAll($criteria); $diaids = ConvertUtil::getSubByKey($res, "diaryid"); $score = $this->getDbConnection()->createCommand()->select("SUM(integration)")->from($this->tableName())->where(sprintf("FIND_IN_SET(diaryid,'%s')", implode(",", $diaids)))->queryScalar(); return intval($score); }
public function run() { $this->checkReviewAccess(); $uid = $this->getUid(); $time = StatCommonUtil::getCommonTimeScope(); $list = Diary::model()->fetchAddTimeByUid($uid, $time["start"], $time["end"]); $data = array("delay" => $this->getDelay($list), "nums" => $this->getDiaryNums($list)); $this->render(self::VIEW, $data); }
public function getCount() { static $return = array(); if (empty($return)) { $time = $this->getTimeScope(); foreach ($this->getUid() as $uid) { $list = Diary::model()->fetchAddTimeByUid($uid, $time["start"], $time["end"]); $return[$uid]["list"] = $this->ReplenishingDate($list); $return[$uid]["name"] = User::model()->fetchRealnameByUid($uid); } } return $return; }
protected function ReplenishingScore($list) { if (empty($list)) { return $list; } $dateScope = array_fill_keys($this->getDateScope(), "'-'"); $diaryIds = ConvertUtil::getSubByKey($list, "diaryid"); $timeList = Diary::model()->fetchAddTimeByDiaryId($diaryIds); $new = array(); foreach ($timeList as $time) { $dayTime = date("Y-m-d", $time["addtime"]); $new[$dayTime] = $time["diaryid"]; } $this->getLegalScore($dateScope, $new, $list); return $dateScope; }
protected function executeTransaction($conn, $arguments = array(), $options = array()) { $members = Doctrine::getTable('Member')->findAll(Doctrine::HYDRATE_ARRAY); foreach ($members as $member) { for ($i = 0; $i < $options['number']; ++$i) { $diary = new Diary(); $diary->setMemberId($member['id']); $diary->setTitle('title'); $diary->setBody('body'); $diary->setPublicFlag(1); $diary->save(); $diary->free(); $this->logSection('posted a diary', sprintf('%s', $member['id'])); } } }
public function insert(SimpleXMLElement $xml) { $member = Doctrine::getTable('Member')->find($xml->author->id); if (!$member) { return false; } $diary = new Diary(); $diary->setTitle($xml->title); $diary->setBody($xml->content); $diary->setMember($member); $diary->save(); return $diary; }
protected function getSidebarData() { $uid = Ibos::app()->user->uid; $ym = date("Ym"); if (array_key_exists("ym", $_GET)) { $ym = $_GET["ym"]; } if (array_key_exists("diaryDate", $_GET)) { list($year, $month) = explode("-", $_GET["diaryDate"]); $ym = $year . $month; } $currentDay = 0; if (date("m") == substr($ym, 4)) { $currentDay = date("j"); } if (array_key_exists("currentDay", $_GET)) { $currentDay = $_GET["currentDay"]; } $diaryList = Diary::model()->fetchAllByUidAndDiarytime($ym, $uid); $calendarStr = DiaryUtil::getCalendar($ym, $diaryList, $currentDay); return $calendarStr; }
protected function afterAdd($data, $sourceInfo) { if (isset($data["type"])) { if ($data["type"] == "reply") { $this->setParseView("comment", self::REPLY_PARSE_VIEW, "parse"); } else { $this->setParseView("comment", self::COMMENT_PARSE_VIEW, "parse"); } } if (isset($data["stamp"])) { $diaryid = $sourceInfo["diaryid"]; $allStamp = Stamp::model()->fetchAll(array("select" => "id")); $stampArr = ConvertUtil::getSubByKey($allStamp, "id"); $stamp = in_array($data["stamp"], $stampArr) ? intval($data["stamp"]) : 0; if ($stamp == 0) { Diary::model()->modify($diaryid, array("isreview" => 1)); } else { Diary::model()->modify($diaryid, array("isreview" => 1, "stamp" => $stamp)); $uid = Diary::model()->fetchUidByDiaryId($diaryid); DiaryStats::model()->scoreDiary($diaryid, $uid, $stamp); } } }
public function executeCreate(opMailRequest $request) { if (!Doctrine::getTable('SnsConfig')->get('op_diary_plugin_use_email_post', true)) { return sfView::NONE; } $member = $this->getRoute()->getMember(); if (!$member) { return sfView::NONE; } $mailMessage = $request->getMailMessage(); $title = $this->getSubject($mailMessage, '(no title)'); $validator = new opValidatorString(array('rtrim' => true)); try { $body = $validator->clean($mailMessage->getContent()); } catch (Exception $e) { return sfView::ERROR; } $diary = new Diary(); $diary->setMember($member); $diary->setTitle($title); $diary->setBody($body); $diary->setPublicFlag($this->getDefaultPublicFlag($member)); $diaryImages = array(); if (sfConfig::get('app_diary_is_upload_images', true)) { $num = (int) sfConfig::get('app_diary_max_image_file_num', 3); $files = $this->getImageFiles($mailMessage, $num); $i = 1; foreach ($files as $file) { $diaryImage = new DiaryImage(); $diaryImage->setDiary($diary); $diaryImage->setFile($file); $diaryImage->setNumber($i++); $diaryImages[] = $diaryImage; $diary->setHasImages(true); } } $diary->save(); foreach ($diaryImages as $diaryImage) { $diaryImage->save(); } return sfView::NONE; }
public function fetchAllDiaryidByUid($uid) { $records = Diary::model()->fetchAll(array("select" => array("diaryid"), "condition" => "uid=:uid", "params" => array(":uid" => $uid))); $diaryStr = ""; foreach ($records as $diary) { $diaryStr .= $diary["diaryid"] . ","; } if (!empty($diaryStr)) { $diaryStr = substr($diaryStr, 0, -1); } return $diaryStr; }
public function actionSearch() { $keyword = $_POST['keywords']; $boat = $_POST['boat']; $str = ''; echo header("Content-Type: text/html;charset=utf-8"); $model = NULL; if ($keyword) { $str = 'boat like ' . '"' . '%' . $keyword . '%' . '"'; } if ($boat) { if ($str != '') { $str .= ' and '; } $str .= ' boat =' . '"' . $boat . '"'; } $criteria = new CDbCriteria(); // 创建CDbCriteria对象 $criteria->condition = $str; // 设置查询条件 $model = Diary::model()->findAll($criteria); $boat = Boat::model()->findAll(); $this->render('index', array('diary' => $model, 'boat' => $boat)); }
$t->ok($second->isViewable(2), 'OK friend'); $t->ok(!$second->isViewable(10), 'NG others'); // PUBLIC_FLAG_PRIVATE $t->ok($last->isViewable(1), 'OK self'); $t->ok(!$last->isViewable(2), 'NG friend'); $t->ok(!$last->isViewable(10), 'NG others'); $t->diag('Diary::getDiaryImagesJoinFile()'); $t->is($first->getDiaryImagesJoinFile()->count(), 1, 'count 1'); $t->is($second->getDiaryImagesJoinFile()->count(), 0, 'count 0'); $t->diag('Diary::countDiaryComments()'); $t->is($first->countDiaryComments(), 21, 'count 21'); $t->is($second->countDiaryComments(), 0, 'count 0'); $t->diag('Diary::save()'); $conn = Doctrine::getTable('Diary')->getConnection(); $conn->beginTransaction(); $new = new Diary(); $new->member_id = 1; $new->public_flag = DiaryTable::PUBLIC_FLAG_OPEN; $new->save(); $t->is($new->public_flag, DiaryTable::PUBLIC_FLAG_SNS, 'modified public flag'); $t->ok($new->is_open, 'modified is_open flag'); $conn->rollback(); $t->diag('Diary::delete()'); $conn = Doctrine::getTable('Diary')->getConnection(); $conn->beginTransaction(); $file_id = $first->DiaryImages[0]->file_id; $first->delete(); $t->ok(!Doctrine::getTable('DiaryImage')->find(1), 'DiaryImage is deleted'); $t->ok(!Doctrine::getTable('File')->find($file_id), 'File is deleted'); $t->ok(!Doctrine::getTable('FileBin')->find($file_id), 'FileBin is deleted'); $conn->rollback();
public function actionShow() { $diaryid = intval(EnvUtil::getRequest("diaryid")); $uid = Ibos::app()->user->uid; if (empty($diaryid)) { $this->error(Ibos::lang("Parameters error", "error"), $this->createUrl("attention/index")); } $diary = Diary::model()->fetchByPk($diaryid); if (empty($diary)) { $this->error(Ibos::lang("No data found"), $this->createUrl("attention/index")); } if (!ICDiary::checkScope($uid, $diary)) { $this->error(Ibos::lang("You do not have permission to view the log"), $this->createUrl("attention/index")); } Diary::model()->addReaderuidByPK($diary, $uid); $data = Diary::model()->fetchDiaryRecord($diary); $params = array("diary" => ICDiary::processDefaultShowData($diary), "prevAndNextPK" => Diary::model()->fetchPrevAndNextPKByPK($diary["diaryid"]), "data" => $data); if (!empty($diary["attachmentid"])) { $params["attach"] = AttachUtil::getAttach($diary["attachmentid"], true, true, false, false, true); $params["count"] = 0; } $params["allowComment"] = $this->issetSharecomment() || UserUtil::checkIsSub($uid, $diary["uid"]) ? 1 : 0; if (!empty($diary["readeruid"])) { $readerArr = explode(",", $diary["readeruid"]); $params["readers"] = User::model()->fetchAllByPk($readerArr); } else { $params["readers"] = ""; } if (!empty($diary["stamp"])) { $params["stampUrl"] = Stamp::model()->fetchStampById($diary["stamp"]); } $this->setPageTitle(Ibos::lang("Show Attention diary")); $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Personal Office")), array("name" => Ibos::lang("Work diary"), "url" => $this->createUrl("default/index")), array("name" => Ibos::lang("Show Attention diary")))); $this->render("show", $params); }
<?php header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); //ini_set('display_errors', 1); require_once '../../../includes/classes/Db.php'; # Database class. require_once 'inc/Diary.php'; $diary = new Diary(); $diary->dbConn('../../../_db/diary.php'); require 'inc/func.php'; require '../../../includes/classes/Login.php'; # Login class. $login = new Login($diary->sess_dir); $login->startsession(); if (isset($_GET['act']) && $_GET['act'] == 'signout') { $login->login_page = '?act=l'; $login->logout($diary->sessname); $login->redirectIfNotLoggedIn($diary->sessname, '?act=l'); exit; } // End if. if (isset($_GET['act']) && $_GET['act'] == 'l') { $errrotext = $login->processLogin(array('txt_user' => 'Username', 'txt_pass' => 'Password'), $diary); } // End if. require '../../../includes/classes/Document.php'; # Document class.
private function loadCalendar() { list($year, $month, $day) = explode("-", date("Y-m-d")); $diaryList = Diary::model()->fetchAllByUidAndDiarytime($year . $month, Ibos::app()->user->uid); return DiaryUtil::getCalendar($year . $month, $diaryList, $day); }
public function actionSave() { $uid = Ibos::app()->user->uid; $originalPlan = $planOutside = ""; if (array_key_exists("originalPlan", $_POST)) { $originalPlan = $_POST["originalPlan"]; } if (array_key_exists("planOutside", $_POST)) { $planOutside = array_filter($_POST["planOutside"], create_function("\$v", "return !empty(\$v[\"content\"]);")); } if (!empty($originalPlan)) { foreach ($originalPlan as $key => $value) { DiaryRecord::model()->modify($key, array("schedule" => $value)); } } $shareUidArr = isset($_POST["shareuid"]) ? StringUtil::getId($_POST["shareuid"]) : array(); $diary = array("uid" => $uid, "diarytime" => strtotime($_POST["todayDate"]), "nextdiarytime" => strtotime($_POST["plantime"]), "addtime" => TIMESTAMP, "content" => $_POST["diaryContent"], "shareuid" => implode(",", $shareUidArr), "readeruid" => "", "remark" => "", "attention" => ""); $diaryId = Diary::model()->add($diary, true); if (!empty($planOutside)) { DiaryRecord::model()->addRecord($planOutside, $diaryId, strtotime($_POST["todayDate"]), $uid, "outside"); } $plan = array_filter($_POST["plan"], create_function("\$v", "return !empty(\$v[\"content\"]);")); DiaryRecord::model()->addRecord($plan, $diaryId, strtotime($_POST["plantime"]), $uid, "new"); UserUtil::updateCreditByAction("adddiary", $uid); $this->ajaxReturn($diaryId, "JSONP"); }
public function getIsCreateUser($pk, $model) { if ($model == "diary" && Diary::model()->findByPk($pk)->create_user == Yii::app()->user->id) { return true; } else { if ($model == "photo" && Photo::model()->findByPk($pk)->create_user == Yii::app()->user->id) { return true; } else { if ($model == "recent" && Recent::model()->findByPk($pk)->create_user == Yii::app()->user->id) { return true; } else { if ($model == "timeline" && Timeline::model()->findByPk($pk)->create_user == Yii::app()->user->id) { return true; } else { if ($model == "pictue" && Picture::model()->findByPk($pk)->create_user == Yii::app()->user->id) { return true; } } } } } return false; }
private function personal() { $getUid = intval(EnvUtil::getRequest("uid")); $uid = Ibos::app()->user->uid; if (EnvUtil::getRequest("param") == "search") { $this->search(); } $condition = "uid='{$getUid}' AND FIND_IN_SET('{$uid}',shareuid) AND uid NOT IN({$uid})"; $this->_condition = DiaryUtil::joinCondition($this->_condition, $condition); $paginationData = Diary::model()->fetchAllByPage($this->_condition); $attention = DiaryAttention::model()->fetchAllByAttributes(array("uid" => $uid, "auid" => $getUid)); $data = array("pagination" => $paginationData["pagination"], "data" => ICDiary::processDefaultListData($paginationData["data"]), "diaryCount" => Diary::model()->count($this->_condition), "commentCount" => Diary::model()->countCommentByUid($getUid), "user" => User::model()->fetchByUid($getUid), "dashboardConfig" => $this->getDiaryConfig(), "isattention" => empty($attention) ? 0 : 1); $this->setPageTitle(Ibos::lang("Share diary")); $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Personal Office")), array("name" => Ibos::lang("Work diary"), "url" => $this->createUrl("default/index")), array("name" => Ibos::lang("Share diary")))); $this->render("personal", $data); }
protected function getDiaryObject($memberId, $id = null) { if ($id) { if (!($diary = Doctrine::getTable('Diary')->findOneById($id))) { throw new opDiaryPluginAPIException('diary does not exist'); } if (!$diary->isAuthor($memberId)) { throw new opDiaryPluginAPIException('this diary is not yours.'); } } else { $diary = new Diary(); $diary->setMemberId($memberId); } return $diary; }
private function getStampIcon() { if (Ibos::app()->request->isAjaxRequest) { $diaryid = $_GET["diaryid"]; $diary = Diary::model()->fetchByPk($diaryid); if ($diary["stamp"] != 0) { $icon = Stamp::model()->fetchIconById($diary["stamp"]); $this->ajaxReturn(array("isSuccess" => true, "icon" => $icon)); } } }
private function getreaderlist() { if (Ibos::app()->request->isAjaxRequest) { $diaryId = EnvUtil::getRequest("diaryid"); $record = Diary::model()->fetch(array("select" => "readeruid", "condition" => "diaryid=:diaryid", "params" => array(":diaryid" => $diaryId))); $readerUids = $record["readeruid"]; $htmlStr = "<table class=\"pop-table\">"; if (!empty($readerUids)) { $htmlStr .= "<div class=\"da-reviews-avatar\">"; $readerUidArr = explode(",", trim($readerUids, ",")); $users = User::model()->fetchAllByUids($readerUidArr); foreach ($users as $user) { //$htmlStr .= "<a href=\"" . Ibos::app()->createUrl("user/home/index", array("uid" => $user["uid"])) . "\">\n\t\t\t\t\t\t\t\t<img class=\"img-rounded\" src=\"" . $user["avatar_small"] . "\" title=\"" . $user["realname"] . "\" />\n\t\t\t\t\t\t\t</a>"; $htmlStr .= '<a href="' . Ibos::app()->createUrl("user/home/index", array("uid" => $user["uid"])) . '"> <img class="img-rounded" src="' . $user["avatar_small"] . '" title="' . $user["realname"] . '" /> </a>'; } } else { $htmlStr .= "<div><li align=\"middle\">" . Ibos::lang("Has not reader") . "</li>"; } $htmlStr .= "</div></table>"; echo $htmlStr; } }
<?php /* AJAX script that returns: 1. How many days an event has been recorded 2. Last day event was recorded 3. List of other days event was recorded */ ini_set('display_errors', 1); require_once '../../../../../includes/classes/Db.php'; require_once '../../inc/Diary.php'; $diary = new Diary(); $diary->dbConn('../../../../../_db/diary.php'); require '../func.php'; // Prevent access if not logged in! require '../../../../../includes/classes/Login.php'; # Login class. $login = new Login($diary->sess_dir); $login->startsession(); if (!isset($_SESSION[$diary->sessname])) { die('It was a dark, cloudy morning!'); } // End if. // End Access check code. if (isset($_POST['load'])) { $r = $diary->link->prepare("SELECT relatedmainid, text FROM diary_related WHERE date=?"); $r->execute(array($_POST['sel'])); list($relatedmainid, $relatedtext) = $r->fetch(PDO::FETCH_NUM); $r = $diary->link->prepare("SELECT related_id, DATE_FORMAT(date, '%d/%m/%Y') FROM diary_related WHERE relatedmainid=? ORDER BY date"); $r->execute(array($relatedmainid)); $strrelateddates = '';
/** * returns JSON * @param $id */ public function get_diary_events($id) { $diary = Diary::get_by_id($id); /* * { * id: event_id, * title: "le titre de l'event" * allDay: BOOLEAN, * start: "datetime", * end: "datetime", * url: "accede a l'url quand cliquer" * } */ }