コード例 #1
0
ファイル: index.php プロジェクト: difra-org/difra
 private function _showEvent($link)
 {
     $Announcements = \Difra\Plugins\Announcements::getInstance();
     $Announce = $Announcements->getByLink($link);
     if ($Announce === false) {
         throw new \Difra\View\HttpError(404);
         return;
     }
     if ($link != $Announce->getShortLink()) {
         \Difra\View::redirect($Announce->getShortLink());
     }
     $Announce->getXML($this->eventRoot);
     $additionalsFieldsNode = $this->eventRoot->appendChild($this->eventRoot->ownerDocument->createElement('additionalsFields'));
     \Difra\Plugins\Announcements\Additionals::getListXML($additionalsFieldsNode);
 }
コード例 #2
0
ファイル: announcements.php プロジェクト: difra-org/difra
 public function saveAdditionalField($name, $alias, $id = null)
 {
     $A = Announcements\Additionals::create($id);
     $A->setName($name);
     $A->setAlias($alias);
 }
コード例 #3
0
ファイル: additionals.php プロジェクト: difra-org/difra
 public function deleteAction(\Difra\Param\AnyInt $id)
 {
     \Difra\Plugins\Announcements\Additionals::delete($id->val());
     \Difra\Ajaxer::getInstance()->refresh();
 }
コード例 #4
0
ファイル: index.php プロジェクト: difra-org/difra
 public function updateAjaxAction(\Difra\Param\AjaxString $title, \Difra\Param\AjaxString $eventDate, \Difra\Param\AjaxString $beginDate, \Difra\Param\AjaxInt $priorityValue, \Difra\Param\AjaxCheckbox $visible, \Difra\Param\AjaxInt $id, \Difra\Param\AjaxHTML $description, \Difra\Param\AjaxInt $group = null, \Difra\Param\AjaxString $shortDescription = null, \Difra\Param\AjaxString $endDate = null, \Difra\Param\AjaxFile $eventImage = null, \Difra\Param\AjaxData $additionalField = null, \Difra\Param\AjaxString $fromEventDate = null, \Difra\Param\AjaxInt $category = null, \Difra\Param\AjaxString $scheduleName = null, \Difra\Param\AjaxData $scheduleField = null, \Difra\Param\AjaxData $scheduleValue = null, \Difra\Param\AjaxInt $location = null, Param\AjaxInt $userId = null)
 {
     $data = ['title' => $title->val(), 'eventDate' => $eventDate->val(), 'beginDate' => $beginDate->val(), 'id' => $id->val(), 'priority' => $priorityValue->val(), 'visible' => $visible->val(), 'description' => $description];
     $data['shortDescription'] = is_null($shortDescription) ? null : $shortDescription->val();
     $data['group'] = is_null($group) ? null : $group->val();
     $data['endDate'] = is_null($endDate) ? null : $endDate->val();
     $data['category'] = is_null($category) ? null : $category->val();
     $data['fromEventDate'] = is_null($fromEventDate) ? null : $fromEventDate->val();
     $data['location'] = is_null($location) ? null : $location->val();
     if (is_null($data['fromEventDate']) || $data['fromEventDate'] == '' || $data['fromEventDate'] == 'null') {
         $data['fromEventDate'] = $eventDate->val();
     }
     // из админки пока ставим так, потом добавим выбор юзера.
     if (!is_null($userId)) {
         $data['user'] = $userId->val();
     } else {
         $data['user'] = 1;
     }
     $Announcements = \Difra\Plugins\Announcements::getInstance();
     // апдейтим анонс
     $eventId = $Announcements->create($data);
     if (is_null($eventId)) {
         $this->ajax->error(\Difra\Locales::getInstance()->getXPath('announcements/adm/notify/updateError'));
         return;
     }
     // сохраняем дополнительные поля
     if (!is_null($additionalField)) {
         \Difra\Plugins\Announcements\Additionals::saveData($eventId, $additionalField->val());
     }
     if (!is_null($eventImage)) {
         $Announcements->saveImage($eventId, $eventImage);
     }
     // смотрим есть ли расписание
     if (!is_null($scheduleField) && !is_null($scheduleValue)) {
         $scheduleName = !is_null($scheduleName) ? $scheduleName->val() : null;
         $Announcements->saveSchedules($eventId, $scheduleName, $scheduleField->val(), $scheduleValue->val());
     }
     $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('announcements/adm/notify/goodUpdate'));
     $this->ajax->redirect('/adm/announcements/');
 }
コード例 #5
0
ファイル: announcement.php プロジェクト: difra-org/difra
 /**
  * @param int $limit
  * @return self[]
  */
 public static function getForExport($limit = 3)
 {
     $db = MySQL::getInstance();
     $eventsArray = null;
     $query = "SELECT an.*, u.`email`, uf.`value` AS `nickname`, aloc.`locationData`,\n\t\t\t\tIF(`fromEventDate`='0000-00-00', `eventDate`, `fromEventDate`) AS `sortDate`,\n\t\t\t\tDATE_FORMAT( CURRENT_TIMESTAMP, '%Y-%m-%d 00:00:00' ) as `curStamp`\n                    \t\tFROM `announcements` an\n                    \t\t\tLEFT JOIN `users` AS `u` ON u.`id`=an.`user`\n                    \t\t\tLEFT JOIN `users_fields` AS `uf` ON uf.`id`=an.`user` AND uf.`name`='nickname'\n                    \t\t\tLEFT JOIN `anouncements_locations` AS `aloc` ON an.`location`=aloc.`id`\n                    \t\tWHERE an.`exported`=0 AND an.`visible`=1 AND an.`beginDate`<=NOW()\n                    \t\tORDER BY eventDate>=curStamp DESC,\n                    \t\t\tIF(eventDate>=curStamp,sortDate,''), sortDate DESC, priority DESC LIMIT " . intval($limit);
     $res = $db->fetch($query);
     if (!empty($res)) {
         // массивчик id'шников
         $idArray = [];
         foreach ($res as $k => $data) {
             $idArray[] = $data['id'];
         }
         $addData = Additionals::getByIdArray($idArray);
         foreach ($res as $k => $data) {
             $Event = new self();
             if (!empty($addData) && isset($addData[$data['id']]) && !empty($addData[$data['id']])) {
                 foreach ($addData[$data['id']] as $tmpaddData) {
                     $data['additionalData'][] = $tmpaddData;
                 }
             }
             if (isset($data['locationData']) && $data['locationData'] != '') {
                 $data['locationData'] = unserialize($data['locationData']);
             }
             $Event->setObject($data);
             $eventsArray[$data['id']] = $Event;
         }
     }
     return $eventsArray;
 }