示例#1
0
 public function __construct(BASE_CLASS_WidgetParameter $params)
 {
     parent::__construct();
     $service = PostService::getInstance();
     $count = $params->customParamList['count'];
     $previewLength = $params->customParamList['previewLength'];
     $list = $service->findList(0, $count);
     if ((empty($list) || false && !OW::getUser()->isAuthorized('blogs', 'add') && !OW::getUser()->isAuthorized('blogs', 'view')) && !$params->customizeMode) {
         $this->setVisible(false);
         return;
     }
     $posts = array();
     $userService = BOL_UserService::getInstance();
     $postIdList = array();
     foreach ($list as $dto) {
         /* @var $dto Post */
         if (mb_strlen($dto->getTitle()) > 50) {
             $dto->setTitle(UTIL_String::splitWord(UTIL_String::truncate($dto->getTitle(), 50, '...')));
         }
         $text = $service->processPostText($dto->getPost());
         $posts[] = array('dto' => $dto, 'text' => UTIL_String::splitWord(UTIL_String::truncate($text, $previewLength)), 'truncated' => mb_strlen($text) > $previewLength, 'url' => OW::getRouter()->urlForRoute('user-post', array('id' => $dto->getId())));
         $idList[] = $dto->getAuthorId();
         $postIdList[] = $dto->id;
     }
     $commentInfo = array();
     if (!empty($idList)) {
         $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, true, false);
         $this->assign('avatars', $avatars);
         $urls = BOL_UserService::getInstance()->getUserUrlsForList($idList);
         $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('blog-post', $postIdList);
         $toolbars = array();
         foreach ($list as $dto) {
             $toolbars[$dto->getId()] = array(array('class' => 'ow_icon_control ow_ic_user', 'href' => isset($urls[$dto->getAuthorId()]) ? $urls[$dto->getAuthorId()] : '#', 'label' => isset($avatars[$dto->getAuthorId()]['title']) ? $avatars[$dto->getAuthorId()]['title'] : ''), array('class' => 'ow_remark ow_ipc_date', 'label' => UTIL_DateTime::formatDate($dto->getTimestamp())));
         }
         $this->assign('tbars', $toolbars);
     }
     $this->assign('commentInfo', $commentInfo);
     $this->assign('list', $posts);
     if ($service->countPosts() > 0) {
         $toolbar = array();
         if (OW::getUser()->isAuthorized('blogs', 'add')) {
             $toolbar[] = array('label' => OW::getLanguage()->text('blogs', 'add_new'), 'href' => OW::getRouter()->urlForRoute('post-save-new'));
         }
         if (OW::getUser()->isAuthorized('blogs', 'view')) {
             $toolbar[] = array('label' => OW::getLanguage()->text('blogs', 'go_to_blog'), 'href' => Ow::getRouter()->urlForRoute('blogs'));
         }
         if (!empty($toolbar)) {
             $this->setSettingValue(self::SETTING_TOOLBAR, $toolbar);
         }
     }
 }
示例#2
0
 public function __construct(BASE_CLASS_WidgetParameter $params)
 {
     parent::__construct();
     $service = LinkService::getInstance();
     $count = $params->customParamList['count'];
     $list = $service->findList(0, $count);
     if ((empty($list) || false && !OW::getUser()->isAuthorized('links', 'add') && !OW::getUser()->isAuthorized('links', 'view')) && !$params->customizeMode) {
         $this->setVisible(false);
         return;
     }
     $links = array();
     $toolbars = array();
     $userService = BOL_UserService::getInstance();
     $authorIdList = array();
     foreach ($list as $dto) {
         $dto->setUrl(strip_tags($dto->getUrl()));
         $dto->setTitle(strip_tags($dto->getTitle()));
         $dto->setDescription(strip_tags($dto->getDescription()));
         $links[] = array('dto' => $dto);
         $idList[] = $dto->id;
         $authorIdList[] = $dto->getUserId();
     }
     $commentInfo = array();
     $this->assign('avatars', null);
     if (!empty($idList)) {
         $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('link', $idList);
         $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($authorIdList, true, false);
         $this->assign('avatars', $avatars);
         $urls = BOL_UserService::getInstance()->getUserUrlsForList($authorIdList);
     }
     $tbars = array();
     foreach ($list as $dto) {
         $tbars[$dto->getId()] = array(array('class' => 'ow_icon_control ow_ic_user', 'href' => !empty($urls[$dto->getUserId()]) ? $urls[$dto->getUserId()] : '#', 'label' => !empty($avatars[$dto->getUserId()]['title']) ? $avatars[$dto->getUserId()]['title'] : ''), array('class' => 'ow_remark ow_ipc_date', 'label' => UTIL_DateTime::formatDate($dto->getTimestamp())));
     }
     $this->assign('tbars', $tbars);
     $this->assign('commentInfo', $commentInfo);
     $this->assign('list', $links);
     if ($service->countAll()) {
         $toolbar = array();
         if (OW::getUser()->isAuthorized('links', 'add')) {
             $toolbar[] = array('label' => OW::getLanguage()->text('links', 'add_new'), 'href' => OW::getRouter()->urlForRoute('link-save-new'));
         }
         if (OW::getUser()->isAuthorized('links', 'view')) {
             $toolbar[] = array('label' => OW::getLanguage()->text('links', 'go_to_links'), 'href' => Ow::getRouter()->urlForRoute('links'));
         }
         if (!empty($toolbar)) {
             $this->setSettingValue(self::SETTING_TOOLBAR, $toolbar);
         }
     }
 }
示例#3
0
 public function copy_resize_image($tmp_name, $slugimage, $idThumb, $extension, $width = null, $height = null)
 {
     if ($extension == null) {
         $extension = '';
     }
     $storage = OW::getStorage();
     $imagesDir = OW::getPluginManager()->getPlugin('spdownload')->getUserFilesDir();
     $imageName = $slugimage . '_' . $idThumb . '.' . $extension;
     $imagePath = $imagesDir . $imageName;
     $pluginfilesDir = Ow::getPluginManager()->getPlugin('spdownload')->getPluginFilesDir();
     $tmpImgPath = $slugimage . '_' . $idThumb . '.' . $extension;
     $image = new UTIL_Image($tmp_name);
     $image->resizeImage($width, $height)->saveImage($tmpImgPath);
     //Copy file into storage folder
     $storage->copyFile($tmpImgPath, $imagePath);
     unlink($tmpImgPath);
 }
示例#4
0
 public function saveEventImage($imagePath, $imageId)
 {
     $storage = OW::getStorage();
     if ($storage->fileExists($this->generateImagePath($imageId))) {
         $storage->removeFile($this->generateImagePath($imageId));
         $storage->removeFile($this->generateImagePath($imageId, false));
     }
     $pluginfilesDir = Ow::getPluginManager()->getPlugin('eventx')->getPluginFilesDir();
     $tmpImgPath = $pluginfilesDir . 'img_' . uniqid() . '.jpg';
     $tmpIconPath = $pluginfilesDir . 'icon_' . uniqid() . '.jpg';
     $image = new UTIL_Image($imagePath);
     $image->resizeImage(295, null)->saveImage($tmpImgPath)->resizeImage(100, 100, true)->saveImage($tmpIconPath);
     unlink($imagePath);
     $storage->copyFile($tmpIconPath, $this->generateImagePath($imageId));
     $storage->copyFile($tmpImgPath, $this->generateImagePath($imageId, false));
     unlink($tmpImgPath);
     unlink($tmpIconPath);
 }
示例#5
0
文件: export.php 项目: vazahat/dudex
 private function exportThemes(ZipArchive $za, $archiveDir)
 {
     $currentTheme = OW::getThemeManager()->getSelectedTheme()->getDto();
     $currentThemeDir = OW::getThemeManager()->getSelectedTheme()->getRootDir();
     $currentThemeUserfilesDir = OW_DIR_THEME_USERFILES;
     $this->configs['currentTheme'] = array('name' => $currentTheme->name, 'customCss' => $currentTheme->customCss, 'customCssFileName' => $currentTheme->customCssFileName, 'description' => $currentTheme->description, 'isActive' => $currentTheme->isActive, 'sidebarPosition' => $currentTheme->sidebarPosition, 'title' => $currentTheme->title);
     $controlValueList = OW::getDbo()->queryForList(" SELECT * FROM " . BOL_ThemeControlValueDao::getInstance()->getTableName() . " WHERE themeId = :themeId ", array('themeId' => $currentTheme->id));
     foreach ($controlValueList as $controlValue) {
         $this->configs['controlValue'][$controlValue['themeControlKey']] = $controlValue['value'];
     }
     $za->addEmptyDir($archiveDir . '/' . $currentTheme->getName());
     $this->zipFolder($za, $currentThemeDir, $archiveDir . '/' . $currentTheme->getName() . '/');
     $themesDir = Ow::getPluginManager()->getPlugin('dataexporter')->getPluginFilesDir() . 'themes' . DS;
     UTIL_File::copyDir(OW_DIR_THEME_USERFILES, $themesDir);
     $fileList = Ow::getStorage()->getFileNameList(OW_DIR_THEME_USERFILES);
     mkdir($themesDir, 0777);
     foreach ($fileList as $file) {
         if (Ow::getStorage()->isFile($file)) {
             Ow::getStorage()->copyFileToLocalFS($file, $themesDir . mb_substr($file, mb_strlen(OW_DIR_THEME_USERFILES)));
         }
     }
     $za->addEmptyDir($archiveDir . '/themes');
     $this->zipFolder($za, $themesDir, $archiveDir . '/themes/');
 }
示例#6
0
 function addJsLib(OW_Event $e)
 {
     //        OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'jquery.ui.widget.js', "text/javascript");
     //        OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'jquery.ui.menu.js', "text/javascript");
     //        OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'jquery.ui.autocomplete.js', "text/javascript");
     //
     if (!$this->jsLibAdded) {
         $languageCode = GOOGLELOCATION_BOL_LocationService::getInstance()->getLanguageCode();
         $key = Ow::getConfig()->getValue('googlelocation', 'api_key');
         if (!empty($key)) {
             $key = '&key=' . $key;
         }
         $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
         $baseJsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
         OW::getDocument()->addScript($baseJsDir . "jquery-ui.min.js");
         //OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'jquery-ui-1.10.3.custom.min.js');
         OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'jquery.js', null, GOOGLELOCATION_BOL_LocationService::JQUERY_LOAD_PRIORITY);
         OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'jquery.migrate.js', null, GOOGLELOCATION_BOL_LocationService::JQUERY_LOAD_PRIORITY);
         OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'jquery.ui.js', null, GOOGLELOCATION_BOL_LocationService::JQUERY_LOAD_PRIORITY);
         OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('googlelocation')->getStaticCssUrl() . 'location.css');
         OW::getDocument()->addScript($protocol . 'maps.google.com/maps/api/js?sensor=false' . $key . '&language=' . $languageCode);
         OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'InfoBubble.js');
         OW::getDocument()->addOnloadScript('if( !window.map )
         {
             window.map = {};
         }');
         $this->jsLibAdded = 1;
     }
 }
 /**
  * Makes and saves event standard image and icon.
  *
  * @param string $imagePath
  * @param integer $imageId
  */
 public function saveEventImage($tmpPath, $imageId)
 {
     $event = new OW_Event(self::EVENT_BEFORE_IMAGE_UPDATE, array("tmpPath" => $tmpPath, "eventId" => $imageId), array("tmpPath" => $tmpPath));
     OW::getEventManager()->trigger($event);
     $data = $event->getData();
     $imagePath = $data["tmpPath"];
     $storage = OW::getStorage();
     if ($storage->fileExists($this->generateImagePath($imageId))) {
         $storage->removeFile($this->generateImagePath($imageId));
         $storage->removeFile($this->generateImagePath($imageId, false));
     }
     $pluginfilesDir = Ow::getPluginManager()->getPlugin('event')->getPluginFilesDir();
     $tmpImgPath = $pluginfilesDir . 'img_' . uniqid() . '.jpg';
     $tmpIconPath = $pluginfilesDir . 'icon_' . uniqid() . '.jpg';
     $image = new UTIL_Image($imagePath);
     $image->resizeImage(400, null)->saveImage($tmpImgPath)->resizeImage(100, 100, true)->saveImage($tmpIconPath);
     $storage->copyFile($tmpIconPath, $this->generateImagePath($imageId));
     $storage->copyFile($tmpImgPath, $this->generateImagePath($imageId, false));
     OW::getEventManager()->trigger(new OW_Event(self::EVENT_AFTER_IMAGE_UPDATE, array("tmpPath" => $tmpPath, "eventId" => $imageId)));
     unlink($imagePath);
     unlink($tmpImgPath);
     unlink($tmpIconPath);
 }
示例#8
0
 public function __construct($name)
 {
     parent::__construct($name);
     $militaryTime = Ow::getConfig()->getValue('base', 'military_time');
     $language = OW::getLanguage();
     $currentYear = date('Y', time());
     $title = new TextField('title');
     $title->setRequired();
     $title->setLabel($language->text('event', 'add_form_title_label'));
     $event = new OW_Event(self::EVENT_NAME, array('name' => 'title'), $title);
     OW::getEventManager()->trigger($event);
     $title = $event->getData();
     $this->addElement($title);
     $startDate = new DateField('start_date');
     $startDate->setMinYear($currentYear);
     $startDate->setMaxYear($currentYear + 5);
     $startDate->setRequired();
     $event = new OW_Event(self::EVENT_NAME, array('name' => 'start_date'), $startDate);
     OW::getEventManager()->trigger($event);
     $startDate = $event->getData();
     $this->addElement($startDate);
     $startTime = new EventTimeField('start_time');
     $startTime->setMilitaryTime($militaryTime);
     if (!empty($_POST['endDateFlag'])) {
         $startTime->setRequired();
     }
     $event = new OW_Event(self::EVENT_NAME, array('name' => 'start_time'), $startTime);
     OW::getEventManager()->trigger($event);
     $startTime = $event->getData();
     $this->addElement($startTime);
     $endDate = new DateField('end_date');
     $endDate->setMinYear($currentYear);
     $endDate->setMaxYear($currentYear + 5);
     $event = new OW_Event(self::EVENT_NAME, array('name' => 'end_date'), $endDate);
     OW::getEventManager()->trigger($event);
     $endDate = $event->getData();
     $this->addElement($endDate);
     $endTime = new EventTimeField('end_time');
     $endTime->setMilitaryTime($militaryTime);
     $event = new OW_Event(self::EVENT_NAME, array('name' => 'end_time'), $endTime);
     OW::getEventManager()->trigger($event);
     $endTime = $event->getData();
     $this->addElement($endTime);
     $location = new TextField('location');
     $location->setRequired();
     $location->setLabel($language->text('event', 'add_form_location_label'));
     $event = new OW_Event(self::EVENT_NAME, array('name' => 'location'), $location);
     OW::getEventManager()->trigger($event);
     $location = $event->getData();
     $this->addElement($location);
     $whoCanView = new RadioField('who_can_view');
     $whoCanView->setRequired();
     $whoCanView->addOptions(array('1' => $language->text('event', 'add_form_who_can_view_option_anybody'), '2' => $language->text('event', 'add_form_who_can_view_option_invit_only')));
     $whoCanView->setLabel($language->text('event', 'add_form_who_can_view_label'));
     $event = new OW_Event(self::EVENT_NAME, array('name' => 'who_can_view'), $whoCanView);
     OW::getEventManager()->trigger($event);
     $whoCanView = $event->getData();
     $this->addElement($whoCanView);
     $whoCanInvite = new RadioField('who_can_invite');
     $whoCanInvite->setRequired();
     $whoCanInvite->addOptions(array(EVENT_BOL_EventService::CAN_INVITE_PARTICIPANT => $language->text('event', 'add_form_who_can_invite_option_participants'), EVENT_BOL_EventService::CAN_INVITE_CREATOR => $language->text('event', 'add_form_who_can_invite_option_creator')));
     $whoCanInvite->setLabel($language->text('event', 'add_form_who_can_invite_label'));
     $event = new OW_Event(self::EVENT_NAME, array('name' => 'who_can_invite'), $whoCanInvite);
     OW::getEventManager()->trigger($event);
     $whoCanInvite = $event->getData();
     $this->addElement($whoCanInvite);
     $submit = new Submit('submit');
     $submit->setValue($language->text('event', 'add_form_submit_label'));
     $this->addElement($submit);
     $desc = new WysiwygTextarea('desc');
     $desc->setLabel($language->text('event', 'add_form_desc_label'));
     $desc->setRequired();
     $event = new OW_Event(self::EVENT_NAME, array('name' => 'desc'), $desc);
     OW::getEventManager()->trigger($event);
     $desc = $event->getData();
     $this->addElement($desc);
     $imageField = new FileField('image');
     $imageField->setLabel($language->text('event', 'add_form_image_label'));
     $this->addElement($imageField);
     $event = new OW_Event(self::EVENT_NAME, array('name' => 'image'), $imageField);
     OW::getEventManager()->trigger($event);
     $imageField = $event->getData();
     $this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
 }
示例#9
0
文件: service.php 项目: vazahat/dudex
 public function saveImage($goalId, $imagePath, $imageId)
 {
     $storage = OW::getStorage();
     $goal = $this->goalDao->findById($goalId);
     if (!$imageId) {
         $imageId = uniqid();
         $goal->image = $imageId;
         $this->goalDao->save($goal);
     } elseif ($storage->fileExists($this->generateImagePath($imageId))) {
         $storage->removeFile($this->generateImagePath($imageId));
         $storage->removeFile($this->generateImagePath($imageId, false));
         $imageId = uniqid();
         $goal->image = $imageId;
         $this->goalDao->save($goal);
     }
     $pluginfilesDir = Ow::getPluginManager()->getPlugin('ocsfundraising')->getPluginFilesDir();
     $tmpImgPath = $pluginfilesDir . 'project_image_' . $imageId . '.jpg';
     $tmpIconPath = $pluginfilesDir . 'project_icon_' . $imageId . '.jpg';
     $image = new UTIL_Image($imagePath);
     $image->resizeImage(300, null)->saveImage($tmpImgPath)->resizeImage(170, 130, true)->saveImage($tmpIconPath);
     unlink($imagePath);
     $storage->copyFile($tmpIconPath, $this->generateImagePath($imageId));
     $storage->copyFile($tmpImgPath, $this->generateImagePath($imageId, false));
     unlink($tmpImgPath);
     unlink($tmpIconPath);
 }
示例#10
0
    function addJsLib(OW_Event $e)
    {
        //        OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'jquery.ui.widget.js', "text/javascript");
        //        OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'jquery.ui.menu.js', "text/javascript");
        //        OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'jquery.ui.autocomplete.js', "text/javascript");
        //
        if (!$this->jsLibAdded) {
            $languageCode = GOOGLELOCATION_BOL_LocationService::getInstance()->getLanguageCode();
            $key = Ow::getConfig()->getValue('googlelocation', 'api_key');
            if (!empty($key)) {
                $key = '&key=' . $key;
            }
            $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
            $baseJsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
            OW::getDocument()->addScript($baseJsDir . "jquery-ui.min.js");
            //OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'jquery-ui-1.10.3.custom.min.js');
            OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'jquery.js', null, GOOGLELOCATION_BOL_LocationService::JQUERY_LOAD_PRIORITY);
            OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'jquery.migrate.js', null, GOOGLELOCATION_BOL_LocationService::JQUERY_LOAD_PRIORITY);
            OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'jquery.ui.js', null, GOOGLELOCATION_BOL_LocationService::JQUERY_LOAD_PRIORITY);
            OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('googlelocation')->getStaticCssUrl() . 'location.css');
            //OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('googlelocation')->getStaticCssUrl() . 'jquery-ui.css');
            OW::getDocument()->addScript($protocol . 'maps.google.com/maps/api/js?sensor=false' . $key . '&language=' . $languageCode);
            OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'InfoBubble.js');
            OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'markerclusterer.js');
            OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'map.js', "text/javascript", GOOGLELOCATION_BOL_LocationService::JQUERY_LOAD_PRIORITY + 1);
            OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'autocomplete.js', "text/javascript", GOOGLELOCATION_BOL_LocationService::JQUERY_LOAD_PRIORITY + 1);
            OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'map_hint.js');
            $hintTemplate = new GOOGLELOCATION_CMP_MapHintTemplate();
            $template = $hintTemplate->render();
            OW::getDocument()->addOnloadScript('

            $("head").append(' . json_encode($template) . ')


            if( !window.map )
            {
                window.map = {};
            }
            $( document ).ready(function() { 
                if ( !window.googlelocation_hint_init )
                {
                    GoogleMapLocationHint.LAUNCHER().init(' . json_encode(GOOGLELOCATION_BOL_LocationService::getInstance()->getDefaultMarkerIcon()) . ');
                    window.googlelocation_hint_init = true;
                }
            });
            ');
            $this->jsLibAdded = 1;
        }
    }
示例#11
0
文件: Service.php 项目: vazahat/dudex
 public static function getValidDir()
 {
     $dir = Ow::getPluginManager()->getPlugin('ynmediaimporter')->getUserFilesDir();
     foreach (array(date('Y'), date('m'), date('d')) as $sub) {
         $dir = $dir . $sub . '/';
         if (!realpath($dir)) {
             if (!mkdir($dir, 0777)) {
                 throw new Exception("{$dir} is not writeable or is not exists!");
             }
         }
     }
     return $dir;
 }
示例#12
0
文件: base.php 项目: vazahat/dudex
 public function __construct($name)
 {
     parent::__construct($name);
     $militaryTime = Ow::getConfig()->getValue('base', 'military_time');
     $language = OW::getLanguage();
     $currentYear = date('Y', time());
     $title = new TextField('title');
     $title->setRequired();
     $title->setLabel($language->text('eventx', 'add_form_title_label'));
     $event = new OW_Event(self::EVENTX_NAME, array('name' => 'title'), $title);
     OW::getEventManager()->trigger($event);
     $title = $event->getData();
     $this->addElement($title);
     $startDate = new DateField('start_date');
     $startDate->setMinYear($currentYear);
     $startDate->setMaxYear($currentYear + 5);
     $startDate->setRequired();
     $event = new OW_Event(self::EVENTX_NAME, array('name' => 'start_date'), $startDate);
     OW::getEventManager()->trigger($event);
     $startDate = $event->getData();
     $this->addElement($startDate);
     $startTime = new EventTimeField('start_time');
     $startTime->setMilitaryTime($militaryTime);
     if (!empty($_POST['endDateFlag'])) {
         $startTime->setRequired();
     }
     $event = new OW_Event(self::EVENTX_NAME, array('name' => 'start_time'), $startTime);
     OW::getEventManager()->trigger($event);
     $startTime = $event->getData();
     $this->addElement($startTime);
     $endDate = new DateField('end_date');
     $endDate->setMinYear($currentYear);
     $endDate->setMaxYear($currentYear + 5);
     $event = new OW_Event(self::EVENTX_NAME, array('name' => 'end_date'), $endDate);
     OW::getEventManager()->trigger($event);
     $endDate = $event->getData();
     $this->addElement($endDate);
     $endTime = new EventTimeField('end_time');
     $endTime->setMilitaryTime($militaryTime);
     $event = new OW_Event(self::EVENTX_NAME, array('name' => 'end_time'), $endTime);
     OW::getEventManager()->trigger($event);
     $endTime = $event->getData();
     $this->addElement($endTime);
     if (OW::getConfig()->getValue('eventx', 'enableCategoryList') == '1') {
         if (OW::getConfig()->getValue('eventx', 'enableMultiCategories') == 1) {
             $element = new CheckboxGroup('event_category');
             $element->setColumnCount(3);
         } else {
             $element = new SelectBox('event_category');
         }
         $element->setRequired(true);
         $element->setLabel($language->text('eventx', 'event_category_label'));
         foreach (EVENTX_BOL_EventService::getInstance()->getCategoriesList() as $category) {
             $element->addOption($category->id, $category->name);
         }
         $this->addElement($element);
     }
     $maxInvites = new TextField('max_invites');
     $maxInvites->setRequired();
     $validator = new IntValidator(0);
     $validator->setErrorMessage($language->text('eventx', 'invalid_integer_value'));
     $maxInvites->addValidator($validator);
     $maxInvites->setLabel($language->text('eventx', 'add_form_maxinvites_label'));
     $this->addElement($maxInvites);
     $location = new TextField('location');
     $location->setRequired();
     $location->setId('location');
     $location->setLabel($language->text('eventx', 'add_form_location_label'));
     $event = new OW_Event(self::EVENTX_NAME, array('name' => 'location'), $location);
     OW::getEventManager()->trigger($event);
     $location = $event->getData();
     $this->addElement($location);
     $whoCanView = new RadioField('who_can_view');
     $whoCanView->setRequired();
     $whoCanView->addOptions(array('1' => $language->text('eventx', 'add_form_who_can_view_option_anybody'), '2' => $language->text('eventx', 'add_form_who_can_view_option_invit_only')));
     $whoCanView->setLabel($language->text('eventx', 'add_form_who_can_view_label'));
     $event = new OW_Event(self::EVENTX_NAME, array('name' => 'who_can_view'), $whoCanView);
     OW::getEventManager()->trigger($event);
     $whoCanView = $event->getData();
     $this->addElement($whoCanView);
     $whoCanInvite = new RadioField('who_can_invite');
     $whoCanInvite->setRequired();
     $whoCanInvite->addOptions(array(EVENTX_BOL_EventService::CAN_INVITE_PARTICIPANT => $language->text('eventx', 'add_form_who_can_invite_option_participants'), EVENTX_BOL_EventService::CAN_INVITE_CREATOR => $language->text('eventx', 'add_form_who_can_invite_option_creator')));
     $whoCanInvite->setLabel($language->text('eventx', 'add_form_who_can_invite_label'));
     $event = new OW_Event(self::EVENTX_NAME, array('name' => 'who_can_invite'), $whoCanInvite);
     OW::getEventManager()->trigger($event);
     $whoCanInvite = $event->getData();
     $this->addElement($whoCanInvite);
     $desc = new WysiwygTextarea('desc');
     $desc->setLabel($language->text('eventx', 'add_form_desc_label'));
     $desc->setRequired();
     $event = new OW_Event(self::EVENTX_NAME, array('name' => 'desc'), $desc);
     OW::getEventManager()->trigger($event);
     $desc = $event->getData();
     $this->addElement($desc);
     $imageField = new FileField('image');
     $imageField->setLabel($language->text('eventx', 'add_form_image_label'));
     $this->addElement($imageField);
     if (OW::getConfig()->getValue('eventx', 'enableTagsList') == '1') {
         $tags = new TagsInputField('tags');
         $tags->setId('tags');
         $tags->setLabel($language->text('base', 'tags_cloud_cap_label'));
         $this->addElement($tags);
     }
     $submit = new Submit('submit');
     $submit->setValue($language->text('eventx', 'add_form_submit_label'));
     $this->addElement($submit);
     $event = new OW_Event(self::EVENTX_NAME, array('name' => 'image'), $imageField);
     OW::getEventManager()->trigger($event);
     $imageField = $event->getData();
     $this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
 }
示例#13
0
 public function onUserRegister(OW_Event $event)
 {
     //	init
     $params = $event->getParams();
     $signupData = OW::getSession()->get(YNSOCIALCONNECT_CTRL_Sync::SESSION_SIGNUP_DATA);
     if (NULL != $params && is_array($params) && NULL != $signupData) {
         //	process
         ////		update ow_base_remote_auth
         $authAdapter = new YNSOCIALCONNECT_CLASS_AuthAdapter($signupData['identity'], $signupData['service']);
         $authAdapter->register($params['userId']);
         ////		update agent table in social connect
         $provider = YNSOCIALCONNECT_BOL_ServicesService::getInstance()->getProvider($signupData['service']);
         $entity = new YNSOCIALCONNECT_BOL_Agents();
         $entity->userId = (int) $params['userId'];
         $entity->identity = $signupData['identity'];
         $entity->serviceId = $provider->id;
         $entity->ordering = 0;
         $entity->status = 'login';
         $entity->login = '******';
         $entity->data = base64_encode(serialize($signupData['user']));
         $entity->tokenData = base64_encode(serialize($signupData['user']));
         $entity->token = time();
         $entity->createdTime = time();
         $entity->loginTime = time();
         $entity->logoutTime = time();
         YNSOCIALCONNECT_BOL_AgentsService::getInstance()->save($entity);
         ////add token in social bridge
         $oBridge = YNSOCIALCONNECT_CLASS_SocialBridge::getInstance();
         if ($oBridge->hasProvider(strtolower($signupData['service']))) {
             $core = new YNSOCIALBRIDGE_CLASS_Core();
             $obj = $core->getInstance($signupData['service']);
             $obj->saveToken();
         }
         ////update signup statistic
         YNSOCIALCONNECT_BOL_ServicesService::getInstance()->updateStatistics($signupData['service'], 'signup');
         ////add user linking
         $entityUserlinking = new YNSOCIALCONNECT_BOL_Userlinking();
         $entityUserlinking->userId = (int) $params['userId'];
         $entityUserlinking->identity = $signupData['identity'];
         $entityUserlinking->serviceId = $provider->id;
         YNSOCIALCONNECT_BOL_UserlinkingService::getInstance()->save($entityUserlinking);
         //	end
         if (isset($_SESSION['socialbridge_session'][$signupData['service']])) {
             unset($_SESSION['socialbridge_session'][$signupData['service']]);
         }
         ////		clear session
         OW::getSession()->delete(YNSOCIALCONNECT_CTRL_Sync::SESSION_SIGNUP_DATA);
         //	update avatar
         ////	if avatar doesn't exist, update with profile image
         if (in_array($signupData['service'], array('facebook', 'linkedin', 'twitter'))) {
             $useProfilePhoto = OW::getSession()->get(YNSOCIALCONNECT_CMP_ViewInJoinPage::SESSION_USE_PROFILE_PHOTO);
             if ($useProfilePhoto == null || $useProfilePhoto != 'not_use') {
                 $avatar = BOL_AvatarService::getInstance()->findByUserId($params['userId']);
                 if (!$avatar) {
                     $profilePicture = YNSOCIALCONNECT_CLASS_SocialConnect::getInstance()->getPhotoUrlFromTokenData($signupData['user'], $signupData['service']);
                     //	with facebook, linkedin, twitter
                     if ($profilePicture != null) {
                         $pluginfilesDir = Ow::getPluginManager()->getPlugin('ynsocialconnect')->getPluginFilesDir();
                         $tmpImgPath = $pluginfilesDir . 'img_' . uniqid() . '.jpg';
                         YNSOCIALCONNECT_CLASS_SocialConnect::getInstance()->fetchImage($profilePicture, $tmpImgPath);
                         BOL_AvatarService::getInstance()->setUserAvatar($params['userId'], $tmpImgPath);
                         @unlink($tmpImgPath);
                     }
                 }
             }
         }
         if (isset($params['quick_signup']) && $params['quick_signup']) {
             $userId = (int) $params['userId'];
             $event = new OW_Event('feed.action', array('pluginKey' => 'base', 'entityType' => 'user_join', 'entityId' => $userId, 'userId' => $userId, 'replace' => true), array('string' => OW::getLanguage()->text('base', 'feed_user_join'), 'view' => array('iconClass' => 'ow_ic_user')));
             OW::getEventManager()->trigger($event);
         }
     }
 }