コード例 #1
0
ファイル: EventsTest.php プロジェクト: notzen/concrete5-tests
 /**
  * @todo Implement testFire().
  */
 public function testFire()
 {
     $observer = new EventsTestObserver();
     $this->object->extend('fire', $observer, 'invoke', null);
     $this->object->fire('dontfire', array('a' => 1, 'b' => 2));
     $this->assertEquals(0, $observer->invoked);
     $this->object->fire('fire', array('a' => 18, 'b' => 81));
     $this->assertEquals(1, $observer->invoked);
     $this->assertEquals(81, $observer->lastArgs['b']);
 }
コード例 #2
0
 public function approve(WorkflowProgress $wp)
 {
     $c = Page::getByID($this->getRequestedPageID());
     $v = CollectionVersion::get($c, $this->cvID);
     $v->approve(false);
     Events::fire('on_page_version_submit_approve', $c);
     $wpr = new WorkflowProgressResponse();
     $wpr->setWorkflowProgressResponseURL(BASE_URL . DIR_REL . '/' . DISPATCHER_FILENAME . '?cID=' . $c->getCollectionID());
     return $wpr;
 }
コード例 #3
0
 public function __construct()
 {
     $this->stateProvinces['GB'] = $this->stateProvinces['UK'];
     $stateProvincesFromEvent = Events::fire('on_get_states_provinces_list', $this->stateProvinces);
     if (is_array($stateProvincesFromEvent)) {
         $this->stateProvinces = $stateProvincesFromEvent;
     } else {
         foreach (array_keys($this->stateProvinces) as $country) {
             asort($this->stateProvinces[$country]);
         }
     }
 }
コード例 #4
0
ファイル: countries.php プロジェクト: Mihail9575/concrete5
 public function __construct()
 {
     Loader::library('3rdparty/Zend/Locale');
     $countries = Zend_Locale::getTranslationList('territory', Localization::activeLocale(), 2);
     unset($countries['FX'], $countries['IM'], $countries['JE'], $countries['NT'], $countries['PU'], $countries['ZZ'], $countries['CS'], $countries['CT'], $countries['DD'], $countries['PC'], $countries['PZ'], $countries['SU'], $countries['VD'], $countries['YD']);
     $countriesFromEvent = Events::fire('on_get_countries_list', $countries);
     if (is_array($countriesFromEvent)) {
         $countries = $countriesFromEvent;
     } else {
         asort($countries, SORT_LOCALE_STRING);
     }
     $this->countries = $countries;
 }
コード例 #5
0
 public function approve(WorkflowProgress $wp)
 {
     $s = Stack::getByID($this->getRequestedPageID());
     $v = CollectionVersion::get($s, $this->cvID);
     $v->approve(false);
     if ($s->getStackName() != $v->getVersionName()) {
         // The stack name has changed so we need to
         // update that for the stack object as well.
         $s->update(array('stackName' => $v->getVersionName()));
     }
     Events::fire('on_page_version_submit_approve', $s);
     $wpr = new WorkflowProgressResponse();
     $wpr->setWorkflowProgressResponseURL(BASE_URL . DIR_REL . '/' . DISPATCHER_FILENAME . '?cID=' . $s->getCollectionID());
     return $wpr;
 }
コード例 #6
0
ファイル: users_friends.php プロジェクト: rii-J/concrete5-de
	static function removeFriend($friendUID,$uID=0){
		if( !intval($friendUID) ) return false;
		if( !intval($uID) ){
			$u = new User();
			if(!$u || !intval($u->uID)) return false;
			$uID=$u->uID;
		}
		$db = Loader::db();	 
		$vals = array( $friendUID, $uID);
		$sql = 'DELETE FROM UsersFriends WHERE friendUID=? AND uID=?'; 
		$ret = Events::fire('on_user_friend_remove', $uID, $friendUID);
		if($ret < 0) {
			return;
		}
		$db->query($sql,$vals); 
		return true;
	}		
コード例 #7
0
ファイル: states_provinces.php プロジェクト: Zyqsempai/amanet
 public function reset()
 {
     $locale = Localization::activeLocale();
     if ($locale === $this->locale) {
         return;
     }
     $this->locale = $locale;
     $this->stateProvinces['GB'] = $this->stateProvinces['UK'];
     $stateProvincesFromEvent = Events::fire('on_get_states_provinces_list', $this->stateProvinces);
     if (is_array($stateProvincesFromEvent)) {
         $this->stateProvinces = $stateProvincesFromEvent;
     } else {
         foreach (array_keys($this->stateProvinces) as $country) {
             if (!in_array($country, $this->sortedCountries)) {
                 asort($this->stateProvinces[$country]);
             }
         }
     }
 }
コード例 #8
0
ファイル: cache.php プロジェクト: ojalehto/concrete5-legacy
 /** 
  * Completely flushes the cache
  */
 public function flush()
 {
     $db = Loader::db();
     $r = $db->MetaTables();
     // flush the CSS cache
     if (is_dir(DIR_FILES_CACHE . '/' . DIRNAME_CSS)) {
         $fh = Loader::helper("file");
         $fh->removeAll(DIR_FILES_CACHE . '/' . DIRNAME_CSS);
     }
     $pageCache = PageCache::getLibrary();
     if (is_object($pageCache)) {
         $pageCache->flush();
     }
     if (in_array('Config', $r)) {
         // clear the environment overrides cache
         $env = Environment::get();
         $env->clearOverrideCache();
         if (in_array('btCachedBlockRecord', $db->MetaColumnNames('Blocks'))) {
             $db->Execute('update Blocks set btCachedBlockRecord = null');
         }
         if (in_array('CollectionVersionBlocksOutputCache', $r)) {
             $db->Execute('truncate table CollectionVersionBlocksOutputCache');
         }
     }
     $loc = CacheLocal::get();
     $loc->cache = array();
     $cache = Cache::getLibrary();
     if ($cache) {
         $cache->setOption('caching', true);
         $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     }
     if (function_exists('apc_clear_cache')) {
         apc_clear_cache();
     }
     Events::fire('on_cache_flush', $cache);
     return true;
 }
コード例 #9
0
ファイル: groups.php プロジェクト: notzen/concrete5
		function add($gName, $gDescription) {
			$db = Loader::db();
			$v = array($gName, $gDescription);
			$r = $db->prepare("insert into Groups (gName, gDescription) values (?, ?)");
			$res = $db->Execute($r, $v);
			
			if ($res) {
				$ng = Group::getByID($db->Insert_ID());
				Events::fire('on_group_add', $ng);
				return $ng;
			}
		}
コード例 #10
0
 /** 
  * Loads the BlockRecord class based on its attribute names
  * @return void
  */
 protected function load()
 {
     if ($this->btTable) {
         if ($this->btCacheBlockRecord && $this->btCachedBlockRecord && ENABLE_BLOCK_CACHE) {
             $this->record = unserialize($this->btCachedBlockRecord);
         } else {
             $this->record = new BlockRecord($this->btTable);
             $this->record->bID = $this->bID;
             $this->record->Load('bID=' . $this->bID);
             if ($this->btCacheBlockRecord && ENABLE_BLOCK_CACHE) {
                 // this is the first time we're loading
                 $record = serialize($this->record);
                 $db = Loader::db();
                 $db->Execute('update Blocks set btCachedBlockRecord = ? where bID = ?', array($record, $this->bID));
             }
         }
     }
     $ret = Events::fire('on_block_load', $this->record, $this->btHandle, $this->bID);
     if ($ret && is_object($ret)) {
         $this->record = $ret;
     }
     if (is_object($this->record)) {
         foreach ($this->record as $key => $value) {
             $this->{$key} = $value;
             $this->set($key, $value);
         }
     }
 }
コード例 #11
0
		protected function notifyAdmin($offenderID) {
			$offender = UserInfo::getByID($offenderID);
			Events::fire('on_private_message_over_limit', $offender);
			$admin = UserInfo::getByID(USER_SUPER_ID);
			
			Log::addEntry(t("User: %s has tried to send more than %s private messages within %s minutes", $offender->getUserName(), USER_PRIVATE_MESSAGE_MAX, USER_PRIVATE_MESSAGE_MAX_TIME_SPAN),t('warning'));
			
			Loader::helper('mail');
			$mh = new MailHelper();
			
			$mh->addParameter('offenderUname', $offender->getUserName());
			$mh->addParameter('profileURL', BASE_URL . View::url('/profile', 'view', $offender->getUserID()));
			$mh->addParameter('profilePreferencesURL', BASE_URL . View::url('/profile/edit'));
			
			$mh->to($admin->getUserEmail());
			$mh->load('private_message_admin_warning');
			$mh->sendMail();
		}
コード例 #12
0
ファイル: url_slug.php プロジェクト: Zyqsempai/amanet
<?php

defined('C5_EXECUTE') or die("Access Denied.");
if (Loader::helper('validation/token')->validate('get_url_slug', $_REQUEST['token'])) {
    $lang = LANGUAGE;
    if (isset($_REQUEST['parentID']) && ($multilingual = Package::getByHandle('multilingual'))) {
        $ms = MultilingualSection::getBySectionOfSite(Page::getByID($_REQUEST['parentID']));
        if (is_object($ms)) {
            $lang = $ms->getLanguage();
        }
    }
    $text = Loader::helper('text');
    $name = $text->urlify($_REQUEST['name'], PAGE_PATH_SEGMENT_MAX_LENGTH, $lang);
    $ret = Events::fire('on_page_urlify', $_REQUEST['name']);
    if ($ret) {
        $name = $ret;
    }
    echo $name;
}
コード例 #13
0
ファイル: view.php プロジェクト: Mihail9575/concrete5
 /**
  * render takes one argument - the item being rendered - and it can either be a path or a page object
  * @access public
  * @param string $view
  * @param array $args
  * @return void
  */
 public function render($view, $args = null)
 {
     if (is_array($args)) {
         extract($args);
     }
     // strip off a slash if there is one at the end
     if (is_string($view)) {
         if (substr($view, strlen($view) - 1) == '/') {
             $view = substr($view, 0, strlen($view) - 1);
         }
     }
     $dsh = Loader::helper('concrete/dashboard');
     $wrapTemplateInTheme = false;
     $this->checkMobileView();
     if (defined('DB_DATABASE') && $view !== '/upgrade') {
         Events::fire('on_start', $this);
     }
     // Extract controller information from the view, and put it in the current context
     if (!isset($this->controller)) {
         $this->controller = Loader::controller($view);
         $this->controller->setupAndRun();
     }
     if ($this->controller->getRenderOverride() != '') {
         $view = $this->controller->getRenderOverride();
     }
     // Determine which inner item to load, load it, and stick it in $innerContent
     $content = false;
     ob_start();
     if ($view instanceof Page) {
         $_pageBlocks = $view->getBlocks();
         if (!$dsh->inDashboard()) {
             $_pageBlocksGlobal = $view->getGlobalBlocks();
             $_pageBlocks = array_merge($_pageBlocks, $_pageBlocksGlobal);
         }
         // do we have any custom menu plugins?
         $cp = new Permissions($view);
         if ($cp->canViewToolbar()) {
             $ih = Loader::helper('concrete/interface/menu');
             $_interfaceItems = $ih->getPageHeaderMenuItems();
             foreach ($_interfaceItems as $_im) {
                 $_controller = $_im->getController();
                 $_controller->outputAutoHeaderItems();
             }
             unset($_interfaceItems);
             unset($_im);
             unset($_controller);
         }
         unset($_interfaceItems);
         unset($_im);
         unset($_controller);
         // now, we output all the custom style records for the design tab in blocks/areas on the page
         $c = $this->getCollectionObject();
         $view->outputCustomStyleHeaderItems();
         $viewPath = $view->getCollectionPath();
         $this->viewPath = $viewPath;
         $cFilename = $view->getCollectionFilename();
         $ctHandle = $view->getCollectionTypeHandle();
         $editMode = $view->isEditMode();
         $c = $view;
         $this->c = $c;
         $env = Environment::get();
         // $view is a page. It can either be a SinglePage or just a Page, but we're not sure at this point, unfortunately
         if ($view->getCollectionTypeID() == 0 && $cFilename) {
             $wrapTemplateInTheme = true;
             $cFilename = trim($cFilename, '/');
             $content = $env->getPath(DIRNAME_PAGES . '/' . $cFilename, $view->getPackageHandle());
             $themeFilename = $c->getCollectionHandle() . '.php';
         } else {
             $rec = $env->getRecord(DIRNAME_PAGE_TYPES . '/' . $ctHandle . '.php', $view->getPackageHandle());
             if ($rec->exists()) {
                 $wrapTemplateInTheme = true;
                 $content = $rec->file;
             }
             $themeFilename = $ctHandle . '.php';
         }
     } else {
         if (is_string($view)) {
             // if we're passing a view but our render override is not null, that means that we're passing
             // a new view from within a controller. If that's the case, then we DON'T override the viewPath, we want to keep it
             // In order to enable editable 404 pages, other editable pages that we render without actually visiting
             if (defined('DB_DATABASE') && $view == '/page_not_found') {
                 $pp = Page::getByPath($view);
                 if (!$pp->isError()) {
                     $this->c = $pp;
                 }
             }
             $viewPath = $view;
             if ($this->controller->getRenderOverride() != '' && $this->getCollectionObject() != null) {
                 // we are INSIDE a collection renderring a view. Which means we want to keep the viewPath that of the collection
                 $this->viewPath = $this->getCollectionObject()->getCollectionPath();
             }
             // we're just passing something like "/login" or whatever. This will typically just be
             // internal Concrete stuff, but we also prepare for potentially having something in DIR_FILES_CONTENT (ie: the webroot)
             if (file_exists(DIR_FILES_CONTENT . "/{$view}/" . FILENAME_COLLECTION_VIEW)) {
                 $content = DIR_FILES_CONTENT . "/{$view}/" . FILENAME_COLLECTION_VIEW;
             } else {
                 if (file_exists(DIR_FILES_CONTENT . "/{$view}.php")) {
                     $content = DIR_FILES_CONTENT . "/{$view}.php";
                 } else {
                     if (file_exists(DIR_FILES_CONTENT_REQUIRED . "/{$view}/" . FILENAME_COLLECTION_VIEW)) {
                         $content = DIR_FILES_CONTENT_REQUIRED . "/{$view}/" . FILENAME_COLLECTION_VIEW;
                     } else {
                         if (file_exists(DIR_FILES_CONTENT_REQUIRED . "/{$view}.php")) {
                             $content = DIR_FILES_CONTENT_REQUIRED . "/{$view}.php";
                         } else {
                             if ($this->getCollectionObject() != null && $this->getCollectionObject()->isGeneratedCollection() && $this->getCollectionObject()->getPackageID() > 0) {
                                 //This is a single_page associated with a package, so check the package views as well
                                 $pagePkgPath = Package::getByID($this->getCollectionObject()->getPackageID())->getPackagePath();
                                 if (file_exists($pagePkgPath . "/single_pages/{$view}/" . FILENAME_COLLECTION_VIEW)) {
                                     $content = $pagePkgPath . "/single_pages/{$view}/" . FILENAME_COLLECTION_VIEW;
                                 } else {
                                     if (file_exists($pagePkgPath . "/single_pages/{$view}.php")) {
                                         $content = $pagePkgPath . "/single_pages/{$view}.php";
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             $wrapTemplateInTheme = true;
             $themeFilename = $view . '.php';
         }
     }
     if (is_object($this->c)) {
         $c = $this->c;
         if (defined('DB_DATABASE') && ($view == '/page_not_found' || $view == '/login')) {
             $view = $c;
             $req = Request::get();
             $req->setCurrentPage($c);
             $_pageBlocks = $view->getBlocks();
             $_pageBlocksGlobal = $view->getGlobalBlocks();
             $_pageBlocks = array_merge($_pageBlocks, $_pageBlocksGlobal);
         }
     }
     if (is_array($_pageBlocks)) {
         foreach ($_pageBlocks as $b1) {
             $b1p = new Permissions($b1);
             if ($b1p->canRead()) {
                 $btc = $b1->getInstance();
                 // now we inject any custom template CSS and JavaScript into the header
                 if ('Controller' != get_class($btc)) {
                     $btc->outputAutoHeaderItems();
                 }
                 $btc->runTask('on_page_view', array($view));
             }
         }
     }
     // Determine which outer item/theme to load
     // obtain theme information for this collection
     if (isset($this->themeOverride)) {
         $theme = $this->themeOverride;
     } else {
         if ($this->controller->theme != false) {
             $theme = $this->controller->theme;
         } else {
             if (($tmpTheme = $this->getThemeFromPath($viewPath)) != false) {
                 $theme = $tmpTheme;
             } else {
                 if (is_object($this->c) && ($tmpTheme = $this->c->getCollectionThemeObject()) != false) {
                     $theme = $tmpTheme;
                 } else {
                     $theme = FILENAME_COLLECTION_DEFAULT_THEME;
                 }
             }
         }
     }
     $this->setThemeForView($theme, $themeFilename, $wrapTemplateInTheme);
     // finally, we include the theme (which was set by setTheme and will automatically include innerContent)
     // disconnect from our db and exit
     $this->controller->on_before_render();
     extract($this->controller->getSets());
     extract($this->controller->getHelperObjects());
     if ($content != false && !$this->disableContentInclude) {
         include $content;
     }
     $innerContent = ob_get_contents();
     if (ob_get_level() > OB_INITIAL_LEVEL) {
         ob_end_clean();
     }
     if (defined('DB_DATABASE') && $view !== '/upgrade') {
         Events::fire('on_before_render', $this);
     }
     if (defined('APP_CHARSET')) {
         header("Content-Type: text/html; charset=" . APP_CHARSET);
     }
     if (file_exists($this->theme)) {
         $cache = PageCache::getLibrary();
         $shouldAddToCache = $cache->shouldAddToCache($this);
         if ($shouldAddToCache) {
             $cache->outputCacheHeaders($c);
         }
         ob_start();
         include $this->theme;
         $pageContent = ob_get_contents();
         ob_end_clean();
         $ret = Events::fire('on_page_output', $pageContent);
         if ($ret != '') {
             print $ret;
             $pageContent = $ret;
         } else {
             print $pageContent;
         }
         $cache = PageCache::getLibrary();
         if ($shouldAddToCache) {
             $cache->set($c, $pageContent);
         }
     } else {
         throw new Exception(t('File %s not found. All themes need default.php and view.php files in them. Consult concrete5 documentation on how to create these files.', $this->theme));
     }
     if (defined('DB_DATABASE') && $view !== '/upgrade') {
         Events::fire('on_render_complete', $this);
     }
     if (ob_get_level() == OB_INITIAL_LEVEL) {
         require DIR_BASE_CORE . '/startup/jobs.php';
         require DIR_BASE_CORE . '/startup/shutdown.php';
         exit;
     }
 }
コード例 #14
0
ファイル: groups.php プロジェクト: remkoj/concrete5
		/**
		 * Deletes a group
		 * @return void
		 */
		function delete(){
			// we will NOT let you delete the required groups
			if ($this->gID == REGISTERED_GROUP_ID || $this->gID == GUEST_GROUP_ID) {
				return false;
			}
			
			// run any internal event we have for group deletion
			$ret = Events::fire('on_group_delete', $this);
			if ($ret < 0) {
				return false;
			}
			
			$db = Loader::db(); 
			$r = $db->query("DELETE FROM UserGroups WHERE gID = ?",array(intval($this->gID)) );
			$r = $db->query("DELETE FROM Groups WHERE gID = ?",array(intval($this->gID)) );
			$r = $db->query("DELETE FROM CollectionVersionBlockPermissions WHERE gID = ?",array(intval($this->gID)) );
			$r = $db->query("DELETE FROM PagePermissionPageTypes WHERE gID = ?",array(intval($this->gID)) );
			$r = $db->query("DELETE FROM PagePermissions WHERE gID = ?",array(intval($this->gID)) );
			$r = $db->query("DELETE FROM AreaGroupBlockTypes WHERE gID = ?",array(intval($this->gID)) );
			$r = $db->query("DELETE FROM AreaGroups WHERE gID = ?",array(intval($this->gID)) ); 
		}
コード例 #15
0
ファイル: job.php プロジェクト: ronlobo/concrete5-de
 public function uninstall()
 {
     $ret = Events::fire('on_job_uninstall', $this);
     if ($ret < 0) {
         return $ret;
     }
     $db = Loader::db();
     $db->query('DELETE FROM Jobs WHERE jHandle=?', array($this->jHandle));
 }
コード例 #16
0
ファイル: user.php プロジェクト: ojalehto/concrete5-legacy
 function exitGroup($g)
 {
     // takes a group object, and, if the user is in the group, they exit the group
     if (is_object($g)) {
         $gID = $g->getGroupID();
         $db = Loader::db();
         $ret = Events::fire('on_user_exit_group', $this, $g);
         $q = "delete from UserGroups where uID = '{$this->uID}' and gID = '{$gID}'";
         $r = $db->query($q);
     }
 }
コード例 #17
0
ファイル: page.php プロジェクト: ronlobo/concrete5-de
 /**
  * Adds a new page of a certain type, using a passed associate array to setup value. $data may contain any or all of the following:
  * "uID": User ID of the page's owner
  * "pkgID": Package ID the page belongs to
  * "cName": The name of the page
  * "cHandle": The handle of the page as used in the path
  * "cDatePublic": The date assigned to the page
  * @param collectiontype $ct
  * @param array $data
  * @return page
  **/
 public function add($ct, $data)
 {
     $db = Loader::db();
     $txt = Loader::helper('text');
     // the passed collection is the parent collection
     $cParentID = $this->getCollectionID();
     $u = new User();
     if (isset($data['uID'])) {
         $uID = $data['uID'];
     } else {
         $uID = $u->getUserID();
         $data['uID'] = $uID;
     }
     if (isset($data['pkgID'])) {
         $pkgID = $data['pkgID'];
     } else {
         if ($ct->getPackageID() > 0) {
             $pkgID = $ct->getPackageID();
         } else {
             $pkgID = 0;
         }
     }
     if (isset($data['cName'])) {
         $data['name'] = $data['cName'];
     }
     if (!$data['cHandle']) {
         // make the handle out of the title
         $handle = $txt->urlify($data['name']);
     } else {
         $handle = $txt->urlify($data['cHandle']);
     }
     $handle = str_replace('-', PAGE_PATH_SEPARATOR, $handle);
     $data['handle'] = $handle;
     $dh = Loader::helper('date');
     $cDate = $dh->getSystemDateTime();
     $cDatePublic = $data['cDatePublic'] ? $data['cDatePublic'] : null;
     parent::refreshCache();
     $data['ctID'] = $ct->getCollectionTypeID();
     $cobj = parent::add($data);
     $cID = $cobj->getCollectionID();
     $ctID = $ct->getCollectionTypeID();
     $q = "select p.cID from Pages p inner join CollectionVersions cv on p.cID = cv.cID where cv.ctID = '{$ctID}' and cIsTemplate = '1'";
     $masterCID = $db->getOne($q);
     //$this->rescanChildrenDisplayOrder();
     $cDisplayOrder = $this->getNextSubPageDisplayOrder();
     $cInheritPermissionsFromCID = $this->overrideTemplatePermissions() ? $this->getPermissionsCollectionID() : $masterCID;
     $cInheritPermissionsFrom = $this->overrideTemplatePermissions() ? "PARENT" : "TEMPLATE";
     $ptID = $this->getCollectionThemeID();
     $v = array($cID, $cParentID, $uID, $cInheritPermissionsFrom, $this->overrideTemplatePermissions(), $cInheritPermissionsFromCID, $cDisplayOrder, $pkgID);
     $q = "insert into Pages (cID, cParentID, uID, cInheritPermissionsFrom, cOverrideTemplatePermissions, cInheritPermissionsFromCID, cDisplayOrder, pkgID) values (?, ?, ?, ?, ?, ?, ?, ?)";
     $r = $db->prepare($q);
     $res = $db->execute($r, $v);
     $newCID = $cID;
     if ($res) {
         // Collection added with no problem -- update cChildren on parrent
         Loader::model('page_statistics');
         PageStatistics::incrementParents($newCID);
         if ($r) {
             // now that we know the insert operation was a success, we need to see if the collection type we're adding has a master collection associated with it
             if ($masterCID) {
                 $this->_associateMasterCollectionBlocks($newCID, $masterCID);
                 $this->_associateMasterCollectionAttributes($newCID, $masterCID);
             }
         }
         $pc = Page::getByID($newCID, 'RECENT');
         // run any internal event we have for page addition
         Events::fire('on_page_add', $pc);
         $pc->rescanCollectionPath();
     }
     return $pc;
 }
コード例 #18
0
ファイル: view.php プロジェクト: nbourguig/concrete5
		/**
		 * render takes one argument - the item being rendered - and it can either be a path or a page object
		 * @access public
		 * @param string $view
		 * @param array $args
		 * @return void
		*/	
		public function render($view, $args = null) { 
			
			try {			
				if (is_array($args)) {
					extract($args);
				}
	
				// strip off a slash if there is one at the end
				if (is_string($view)) {
					if (substr($view, strlen($view) - 1) == '/') {
						$view = substr($view, 0, strlen($view) - 1);
					}
				}
				
				$wrapTemplateInTheme = false;

				Events::fire('on_start', $this);
				
				// Extract controller information from the view, and put it in the current context
				if (!isset($this->controller)) {
					$this->controller = Loader::controller($view);
					$this->controller->setupAndRun();
				}

				if ($this->controller->getRenderOverride() != '') {
				   $view = $this->controller->getRenderOverride();
				}
				
				// Determine which inner item to load, load it, and stick it in $innerContent
				$content = false;
								
				ob_start();			
				if ($view instanceof Page) {
					
					$viewPath = $view->getCollectionPath();
					$this->viewPath = $viewPath;
					
					$cFilename = $view->getCollectionFilename();
					$ctHandle = $view->getCollectionTypeHandle();
					$editMode = $view->isEditMode();
					$c = $view;
					$this->c = $c;
					
					// $view is a page. It can either be a SinglePage or just a Page, but we're not sure at this point, unfortunately
					if ($view->getCollectionTypeID() == 0 && $cFilename) {
						$wrapTemplateInTheme = true;
						if (file_exists(DIR_FILES_CONTENT. "{$cFilename}")) {
							$content = DIR_FILES_CONTENT. "{$cFilename}";
						} else if ($view->getPackageID() > 0) {
							$file1 = DIR_PACKAGES . '/' . $view->getPackageHandle() . '/'. DIRNAME_PAGES . $cFilename;
							$file2 = DIR_PACKAGES_CORE . '/' . $view->getPackageHandle() . '/'. DIRNAME_PAGES . $cFilename;
							if (file_exists($file1)) {
								$content = $file1;
							} else if (file_exists($file2)) {
								$content = $file2;
							}
						} else if (file_exists(DIR_FILES_CONTENT_REQUIRED . "{$cFilename}")) {
							$content = DIR_FILES_CONTENT_REQUIRED. "{$cFilename}";
						}
						
						$themeFilename = $c->getCollectionHandle() . '.php';
						
					} else {
						if (file_exists(DIR_BASE . '/' . DIRNAME_PAGE_TYPES . '/' . $ctHandle . '.php')) {
							$content = DIR_BASE . '/' . DIRNAME_PAGE_TYPES . '/' . $ctHandle . '.php';
							$wrapTemplateInTheme = true;
						} else if (file_exists(DIR_BASE_CORE. '/' . DIRNAME_PAGE_TYPES . '/' . $ctHandle . '.php')) {
							$content = DIR_BASE_CORE . '/' . DIRNAME_PAGE_TYPES . '/' . $ctHandle . '.php';
							$wrapTemplateInTheme = true;
						} else if ($view->getPackageID() > 0) {
							$file1 = DIR_PACKAGES . '/' . $view->getPackageHandle() . '/'. DIRNAME_PAGE_TYPES . '/' . $ctHandle . '.php';
							$file2 = DIR_PACKAGES_CORE . '/' . $view->getPackageHandle() . '/'. DIRNAME_PAGE_TYPES . '/' . $ctHandle . '.php';
							if (file_exists($file1)) {
								$content = $file1;
								$wrapTemplateInTheme = true;
							} else if (file_exists($file2)) {
								$content = $file2;
								$wrapTemplateInTheme = true;
							}
						}
						
						$themeFilename = $ctHandle . '.php';
					}
					
					
				} else if (is_string($view)) {
					
					// if we're passing a view but our render override is not null, that means that we're passing 
					// a new view from within a controller. If that's the case, then we DON'T override the viewPath, we want to keep it
					
					// In order to enable editable 404 pages, other editable pages that we render without actually visiting
					if (defined('DB_DATABASE') && $view == '/page_not_found') {
						$pp = Page::getByPath($view);
						if (!$pp->isError()) {
							$this->c = $pp;
						}
					}
					
					$viewPath = $view;
					if ($this->controller->getRenderOverride() != '' && $this->getCollectionObject() != null) {
						// we are INSIDE a collection renderring a view. Which means we want to keep the viewPath that of the collection
						$this->viewPath = $this->getCollectionObject()->getCollectionPath();
					}
					
					// we're just passing something like "/login" or whatever. This will typically just be 
					// internal Concrete stuff, but we also prepare for potentially having something in DIR_FILES_CONTENT (ie: the webroot)
					if (file_exists(DIR_FILES_CONTENT . "/{$view}/" . FILENAME_COLLECTION_VIEW)) {
						$content = DIR_FILES_CONTENT . "/{$view}/" . FILENAME_COLLECTION_VIEW;
					} else if (file_exists(DIR_FILES_CONTENT . "/{$view}.php")) {
						$content = DIR_FILES_CONTENT . "/{$view}.php";
					} else if (file_exists(DIR_FILES_CONTENT_REQUIRED . "/{$view}/" . FILENAME_COLLECTION_VIEW)) {
						$content = DIR_FILES_CONTENT_REQUIRED . "/{$view}/" . FILENAME_COLLECTION_VIEW;
					} else if (file_exists(DIR_FILES_CONTENT_REQUIRED . "/{$view}.php")) {
						$content = DIR_FILES_CONTENT_REQUIRED . "/{$view}.php";
					} else if ($this->getCollectionObject() != null && $this->getCollectionObject()->isGeneratedCollection() && $this->getCollectionObject()->getPackageID() > 0) {
						//This is a single_page associated with a package, so check the package views as well
						$pagePkgPath = Package::getByID($this->getCollectionObject()->getPackageID())->getPackagePath();
						if (file_exists($pagePkgPath . "/single_pages/{$view}/" . FILENAME_COLLECTION_VIEW)) {
							$content = $pagePkgPath . "/single_pages/{$view}/" . FILENAME_COLLECTION_VIEW;
						} else if (file_exists($pagePkgPath . "/single_pages/{$view}.php")) {
							$content = $pagePkgPath . "/single_pages/{$view}.php";
						}
					}
					$wrapTemplateInTheme = true;
					$themeFilename = $view . '.php';
				}
				
				
				if (is_object($this->c)) {
					$c = $this->c;
					if (defined('DB_DATABASE') && $view == '/page_not_found') {
						$view = $c;
						$req = Request::get();
						$req->setCurrentPage($c);
					}
				}
				
				// Determine which outer item/theme to load
				// obtain theme information for this collection
				if (isset($this->themeOverride)) {
					$theme = $this->themeOverride;
				} else if ($this->controller->theme != false) {
					$theme = $this->controller->theme;
				} else if (($tmpTheme = $this->getThemeFromPath($viewPath)) != false) {
					$theme = $tmpTheme;
				} else if (is_object($this->c) && ($tmpTheme = $this->c->getCollectionThemeObject()) != false) {
					$theme = $tmpTheme;
				} else {
					$theme = FILENAME_COLLECTION_DEFAULT_THEME;
				}		
				
				$this->setThemeForView($theme, $themeFilename, $wrapTemplateInTheme);

				// Now, if we're on an actual page, we retrieve all the blocks on the page
				// and store their view states in the local cache (for the page). That way
				// we can add header items and have them show up in the header BEFORE
				// the block itself is actually loaded 			
				
				if ($view instanceof Page) {
					$_pageBlocks = $view->getBlocks();
					$_pageBlocksGlobal = $view->getGlobalBlocks();
					$_pageBlocks = array_merge($_pageBlocks, $_pageBlocksGlobal);
					if ($view->supportsPageCache($_pageBlocks, $this->controller)) {
						$pageContent = $view->getFromPageCache();
						if ($pageContent != false) {
							Events::fire('on_before_render', $this);
							if (defined('APP_CHARSET')) {
								header("Content-Type: text/html; charset=" . APP_CHARSET);
							}
							print($pageContent);
							Events::fire('on_render_complete', $this);
							if (ob_get_level() == OB_INITIAL_LEVEL) {
		
								require(DIR_BASE_CORE . '/startup/shutdown.php');
								exit;
							}
							return;
						}
					}
					
					foreach($_pageBlocks as $b1) {
						$btc = $b1->getInstance();
						// now we inject any custom template CSS and JavaScript into the header
						if('Controller' != get_class($btc)){
							$btc->outputAutoHeaderItems();
						}
						$btc->runTask('on_page_view', array($view));
					}
					
					// do we have any custom menu plugins?
					$cp = new Permissions($view);
					if ($cp->canWrite() || $cp->canAddSubContent() || $cp->canAdminPage() || $cp->canApproveCollection()) { 
						$ih = Loader::helper('concrete/interface/menu');
						$_interfaceItems = $ih->getPageHeaderMenuItems();
						foreach($_interfaceItems as $_im) {
							$_controller = $_im->getController();
							$_controller->outputAutoHeaderItems();
						}
						unset($_interfaceItems);
						unset($_im);
						unset($_controller);
					}
					unset($_interfaceItems);
					unset($_im);
					unset($_controller);
					
					
					// now, we output all the custom style records for the design tab in blocks/areas on the page
					$c = $this->getCollectionObject();
					$view->outputCustomStyleHeaderItems(); 				
				}
	
				// finally, we include the theme (which was set by setTheme and will automatically include innerContent)
				// disconnect from our db and exit

				$this->controller->on_before_render();
				extract($this->controller->getSets());
				extract($this->controller->getHelperObjects());

				if ($content != false) {
					include($content);
				}

				$innerContent = ob_get_contents();
				
				if (ob_get_level() > OB_INITIAL_LEVEL) {
					ob_end_clean();
				}
				
				Events::fire('on_before_render', $this);
				
				if (defined('APP_CHARSET')) {
					header("Content-Type: text/html; charset=" . APP_CHARSET);
				}
				
				if (file_exists($this->theme)) {
					
					ob_start();
					include($this->theme);
					$pageContent = ob_get_contents();
					ob_end_clean();
					
					$ret = Events::fire('on_page_output', $pageContent);
					if($ret != '') {
						print $ret;
					} else {
						print $pageContent;
					}
					
					if ($view instanceof Page) {
						if ($view->supportsPageCache($_pageBlocks, $this->controller)) {
							$view->addToPageCache($pageContent);
						}
					}
					
				} else {
					throw new Exception(t('File %s not found. All themes need default.php and view.php files in them. Consult concrete5 documentation on how to create these files.', $this->theme));
				}
				
				Events::fire('on_render_complete', $this);
				
				if (ob_get_level() == OB_INITIAL_LEVEL) {
	
					require(DIR_BASE_CORE . '/startup/shutdown.php');
					exit;
					
				}
				
			} catch(ADODB_Exception $e) {
				// if it's a database exception we go here.
				if (Config::get('SITE_DEBUG_LEVEL') == DEBUG_DISPLAY_ERRORS) {
					$this->renderError(t('An unexpected error occurred.'), $e->getMessage(), $e);		
				} else {
					$this->renderError(t('An unexpected error occurred.'), t('A database error occurred while processing this request.'), $e);
				}
				
				// log if setup to do so
				if (ENABLE_LOG_ERRORS) {
					$l = new Log(LOG_TYPE_EXCEPTIONS, true, true);
					$l->write(t('Exception Occurred: ') . $e->getMessage());
					$l->write($e->getTraceAsString());
					$l->close();
				}
			} catch (Exception $e) {
				$this->renderError(t('An unexpected error occurred.'), $e->getMessage(), $e);
				// log if setup to do so
				if (ENABLE_LOG_ERRORS) {
					$l = new Log(LOG_TYPE_EXCEPTIONS, true, true);
					$l->write(t('Exception Occurred: ') . $e->getMessage());
					$l->write($e->getTraceAsString());
					$l->close();
				}
			}

		}
コード例 #19
0
ファイル: file.php プロジェクト: notzen/concrete5
	/**
	 * Tracks File Download, takes the cID of the page that the file was downloaded from 
	 * @param int $rcID
	 * @return void
	 */
	public function trackDownload($rcID=NULL){ 
		$u = new User();
		$uID = intval( $u->getUserID() );
		$fv = $this->getVersion();
		$fvID = $fv->getFileVersionID();
		if(!isset($rcID) || !is_numeric($rcID)) {
			$rcID = 0;
		}
		Events::fire('on_file_download', $fv, $u);
		$db = Loader::db();
		$db->Execute('insert into DownloadStatistics (fID, fvID, uID, rcID) values (?, ?, ?, ?)',  array( $this->fID, intval($fvID), $uID, $rcID ) );		
	}
コード例 #20
0
 /** 
  * Loads the BlockRecord class based on its attribute names
  * If ENABLE_ON_BLOCK_LOAD_EVENT is set, fires 'on_block_load'. Event handlers have 
  * the opportunity to return a modified block record.
  * @return void
  */
 protected function load()
 {
     $ret = Events::fire('on_block_load', $this->record, $this->btHandle, $this->bID);
     if ($ret && is_object($ret)) {
         $this->record = $ret;
     }
     if (is_object($this->record)) {
         foreach ($this->record as $key => $value) {
             $this->{$key} = $value;
             $this->set($key, $value);
         }
     }
 }
コード例 #21
0
 function approve()
 {
     $db = Loader::db();
     $u = new User();
     $uID = $u->getUserID();
     $cvID = $this->cvID;
     $cID = $this->cID;
     $c = Page::getByID($cID, $this->cvID);
     $ov = Page::getByID($cID, 'ACTIVE');
     $oldHandle = $ov->getCollectionHandle();
     $newHandle = $this->cvHandle;
     // update a collection updated record
     $dh = Loader::helper('date');
     $db->query('update Collections set cDateModified = ? where cID = ?', array($dh->getLocalDateTime(), $cID));
     // first we remove approval for the other version of this collection
     $v = array($cID);
     $q = "update CollectionVersions set cvIsApproved = 0 where cID = ?";
     $r = $db->query($q, $v);
     $ov->refreshCache();
     // now we approve our version
     $v2 = array($uID, $cID, $cvID);
     $q2 = "update CollectionVersions set cvIsNew = 0, cvIsApproved = 1, cvApproverUID = ? where cID = ? and cvID = ?";
     $r = $db->query($q2, $v2);
     // next, we rescan our collection paths for the particular collection, but only if this isn't a generated collection
     if (($oldHandle != $newHandle || $oldHandle == '') && !$c->isGeneratedCollection()) {
         $c->rescanCollectionPath();
     }
     Events::fire('on_page_version_approve', $c);
     $c->reindex();
     $this->refreshCache();
 }
コード例 #22
0
ファイル: indexed_search.php プロジェクト: Zyqsempai/amanet
 public function getBodyContentFromPage($c)
 {
     $searchableAreaNamesInitial = $this->getSavedSearchableAreas();
     foreach ($this->searchableAreaNamesManual as $sm) {
         $searchableAreaNamesInitial[] = $sm;
     }
     $searchableAreaNames = array();
     if ($this->getSearchableAreaAction() == 'blacklist') {
         $areas = Area::getHandleList();
         foreach ($areas as $arHandle) {
             if (!in_array($arHandle, $searchableAreaNamesInitial)) {
                 $searchableAreaNames[] = $arHandle;
             }
         }
     } else {
         $searchableAreaNames = $searchableAreaNamesInitial;
     }
     if (count($searchableAreaNames) == 0) {
         return false;
     }
     $text = '';
     $tagsToSpaces = array('<br>', '<br/>', '<br />', '<p>', '</p>', '</ p>', '<div>', '</div>', '</ div>', '&nbsp;');
     $blarray = array();
     $db = Loader::db();
     $r = $db->Execute('select bID, arHandle from CollectionVersionBlocks where cID = ? and cvID = ?', array($c->getCollectionID(), $c->getVersionID()));
     $th = Loader::helper('text');
     while ($row = $r->FetchRow()) {
         if (in_array($row['arHandle'], $searchableAreaNames)) {
             $b = Block::getByID($row['bID'], $c, $row['arHandle']);
             if (!is_object($b)) {
                 continue;
             }
             $bi = $b->getInstance();
             $bi->bActionCID = $c->getCollectionID();
             if (method_exists($bi, 'getSearchableContent')) {
                 $searchableContent = $bi->getSearchableContent();
                 if (strlen(trim($searchableContent))) {
                     $text .= $th->decodeEntities(strip_tags(str_ireplace($tagsToSpaces, ' ', $searchableContent)), ENT_QUOTES, APP_CHARSET) . ' ';
                 }
             }
             unset($b);
             unset($bi);
         }
     }
     $returned_text = Events::fire('on_page_body_index', $c, $text);
     if ($returned_text !== null && $returned_text !== false) {
         $text = $returned_text;
     }
     return $text;
 }
コード例 #23
0
ファイル: userinfo.php プロジェクト: rii-J/concrete5-de
		function changePassword($newPassword) { 
			$db = Loader::db();
			if ($this->uID) {
				$v = array(User::encryptPassword($newPassword), $this->uID);
				$q = "update Users set uPassword = ? where uID = ?";
				$r = $db->prepare($q);
				$res = $db->execute($r, $v);

				Events::fire('on_user_change_password', $this, $newPassword);

				return $res;
			}
		}
コード例 #24
0
 function approve($doReindexImmediately = true)
 {
     $db = Loader::db();
     $u = new User();
     $uID = $u->getUserID();
     $cvID = $this->cvID;
     $cID = $this->cID;
     $c = Page::getByID($cID, $this->cvID);
     $ov = Page::getByID($cID, 'ACTIVE');
     $oldHandle = $ov->getCollectionHandle();
     $newHandle = $this->cvHandle;
     // update a collection updated record
     $dh = Loader::helper('date');
     $db->query('update Collections set cDateModified = ? where cID = ?', array($dh->getLocalDateTime(), $cID));
     // first we remove approval for the other version of this collection
     $v = array($cID);
     $q = "update CollectionVersions set cvIsApproved = 0 where cID = ?";
     $r = $db->query($q, $v);
     $ov->refreshCache();
     // now we approve our version
     $v2 = array($uID, $cID, $cvID);
     $q2 = "update CollectionVersions set cvIsNew = 0, cvIsApproved = 1, cvApproverUID = ? where cID = ? and cvID = ?";
     $r = $db->query($q2, $v2);
     // next, we rescan our collection paths for the particular collection, but only if this isn't a generated collection
     // I don't know why but this just isn't reliable. It might be a race condition with the cached page objects?
     /*
     if ((($oldHandle != $newHandle) || $oldHandle == '') && (!$c->isGeneratedCollection())) {
     */
     $c->rescanCollectionPath();
     //}
     // check for related version edits. This only gets applied when we edit global areas.
     $r = $db->Execute('select cRelationID, cvRelationID from CollectionVersionRelatedEdits where cID = ? and cvID = ?', array($cID, $cvID));
     while ($row = $r->FetchRow()) {
         $cn = Page::getByID($row['cRelationID'], $row['cvRelationID']);
         $cnp = new Permissions($cn);
         if ($cnp->canApprovePageVersions()) {
             $v = $cn->getVersionObject();
             $v->approve();
             $r = $db->Execute('delete from CollectionVersionRelatedEdits where cID = ? and cvID = ? and cRelationID = ? and cvRelationID = ?', array($cID, $cvID, $row['cRelationID'], $row['cvRelationID']));
         }
     }
     if ($c->getCollectionInheritance() == 'TEMPLATE') {
         // we make sure to update the cInheritPermissionsFromCID value
         $ct = CollectionType::getByID($c->getCollectionTypeID());
         $masterC = $ct->getMasterTemplate();
         $db->Execute('update Pages set cInheritPermissionsFromCID = ? where cID = ?', array($masterC->getCollectionID(), $c->getCollectioniD()));
     }
     Events::fire('on_page_version_approve', $c);
     $c->reindex(false, $doReindexImmediately);
     $this->refreshCache();
 }
コード例 #25
0
ファイル: file_version.php プロジェクト: nbourguig/concrete5
	public function deny() {
		$db = Loader::db();
		$db->Execute("update FileVersions set fvIsApproved = 0 where fID = ? and fvID = ?", array($this->getFileID(), $this->getFileVersionID()));
		Events::fire('on_file_version_deny', $this);
		$fo = $this->getFile();
		$fo->refreshCache();
	}
コード例 #26
0
ファイル: write.php プロジェクト: nbourguig/concrete5
	public function save() {
		session_write_close();
		if ($this->isPost()) {
			if (intval($this->post('entryID')) > 0) {
				$entry = ComposerPage::getByID($this->post('entryID'), 'RECENT');
			}
			
			if (!is_object($entry)) {
				$this->error->add(t('Invalid page.'));
			} else {
				$ct = CollectionType::getByID($entry->getCollectionTypeID());
			}
		
			$valt = Loader::helper('validation/token');
			$vtex = Loader::helper('validation/strings');
			
			if (!$valt->validate('composer')) {
				$this->error->add($valt->getErrorMessage());
			}
			
			if ($this->post("ccm-submit-publish")) {
				if (!$vtex->notempty($this->post('cName'))) {
					$this->error->add(t('You must provide a name for your page before you can publish it.'));
				}
				
				if ($entry->isComposerDraft()) { 
					if ($ct->getCollectionTypeComposerPublishMethod() == 'CHOOSE' || $ct->getCollectionTypeComposerPublishMethod() == 'PAGE_TYPE') { 
						$parent = Page::getByID($entry->getComposerDraftPublishParentID());
						if (!is_object($parent) || $parent->isError()) {
							$this->error->add(t('Invalid parent page.'));
						} else {
							$cp = new Permissions($parent);
							if (!$cp->canAddSubCollection($ct)) {
								$this->error->add(t('You do not have permissions to add this page type in that location.'));
							}
						}
					} else if ($ct->getCollectionTypeComposerPublishMethod() == 'PARENT') {
						$parent = Page::getByID($ct->getCollectionTypeComposerPublishPageParentID());
					}
				}
			} else if ($this->post('ccm-submit-discard') && !$this->error->has()) {
				if ($entry->isComposerDraft()) {
					$entry->delete();
					$this->redirect('/dashboard/composer/drafts', 'draft_discarded');
				} else {
					// we just discard the most recent changes
					Events::fire('on_composer_delete_draft', $entry);
					$v = CollectionVersion::get($entry, 'RECENT');
					$v->discard();
					$this->redirect('?cID=' . $entry->getCollectionID());
				}
			}
			
			if (!$this->error->has()) {
				
				$data = array('cDatePublic' => Loader::helper('form/date_time')->translate('cDatePublic'), 'cHandle' => Loader::helper('text')->sanitizeFileSystem($this->post('cName')), 'cName' => $this->post('cName'), 'cDescription' => $this->post('cDescription'));
				$entry->getVersionToModify();
				// this is a pain. we have to use composerpage::getbyid again because
				// getVersionToModify is hard-coded to return a page object
				$entry = ComposerPage::getByID($entry->getCollectionID(), 'RECENT');
				$entry->update($data);
				$this->saveData($entry);
				if ($this->post('ccm-submit-publish')) {
					$v = CollectionVersion::get($entry, 'RECENT');
					$v->approve();
					if ($entry->isComposerDraft()) { 
						$entry->move($parent);
						Events::fire('on_composer_publish', $entry);
						$entry->markComposerPageAsPublished();
					}
					$this->redirect('?cID=' . $entry->getCollectionID());
				} else if ($this->post('autosave')) { 
					// this is done by javascript. we refresh silently and send a json success back
					Events::fire('on_composer_save_draft', $entry);
					$json = Loader::helper('json');
					$obj = new stdClass;
					$dh = Loader::helper('date');
					$obj->error = false;
					$obj->time = $dh->getLocalDateTime('now','g:i a');
					$obj->timestamp =date('m/d/Y g:i a');
					print $json->encode($obj);
					exit;
				} else {
					$this->redirect('/dashboard/composer/write', 'edit', $entry->getCollectionID(), 'saved');
				}
			} else if (is_object($entry)) {
				$this->edit($entry->getCollectionID());
			}
			
		} else {
			$this->redirect('/dashboard/composer');	
		}
	}
コード例 #27
0
ファイル: dispatcher.php プロジェクト: nbourguig/concrete5
                $cp->disableWrite();
                break;
            case COLLECTION_NOT_FOUND:
                $v = View::getInstance();
                $v->render('/page_not_found');
                break;
            case COLLECTION_FORBIDDEN:
                $v = View::getInstance();
                $v->setCollectionObject($c);
                $v->render('/page_forbidden');
                break;
        }
    }
    ## Any custom site-related process
    if (file_exists(DIR_BASE . '/config/site_process.php')) {
        require DIR_BASE . '/config/site_process.php';
    }
    ## Make sure that any submitted forms, etc... are handled correctly
    ## This is legacy cms specific stuff, like adding pages
    require dirname(__FILE__) . '/startup/process.php';
    ## Record the view
    $u = new User();
    if (STATISTICS_TRACK_PAGE_VIEWS == 1) {
        $u->recordView($c);
    }
    ## Fire the on_page_view Event
    Events::fire('on_page_view', $c, $u);
    ## now we display (provided we've gotten this far)
    $v = View::getInstance();
    $v->render($c);
}
コード例 #28
0
ファイル: user.php プロジェクト: VonUniGE/concrete5-1
 function recordView($c)
 {
     $db = Loader::db();
     $uID = $this->uID > 0 ? $this->uID : 0;
     $cID = $c->getCollectionID();
     $v = array($cID, $uID);
     $db->query("insert into PageStatistics (cID, uID, date) values (?, ?, NOW())", $v);
     // record a view, arguments are
     // 1. page being viewed
     // 2. user viewing page
     Events::fire('on_page_view', $c, $this);
 }
コード例 #29
0
 protected function finishLogin($loginData = array())
 {
     $u = new User();
     if ($this->post('uMaintainLogin')) {
         $u->setUserForeverCookie();
     }
     if (count($this->locales) > 0) {
         if (Config::get('LANGUAGE_CHOOSE_ON_LOGIN') && $this->post('USER_LOCALE') != '') {
             $u->setUserDefaultLanguage($this->post('USER_LOCALE'));
         }
     }
     // Verify that the user has filled out all
     // required items that are required on register
     // That means users logging in after new user attributes
     // have been created and required will be prompted here to
     // finish their profile
     $this->set('invalidRegistrationFields', false);
     Loader::model('attribute/categories/user');
     $ui = UserInfo::getByID($u->getUserID());
     $aks = UserAttributeKey::getRegistrationList();
     $unfilledAttributes = array();
     foreach ($aks as $uak) {
         if ($uak->isAttributeKeyRequiredOnRegister()) {
             $av = $ui->getAttributeValueObject($uak);
             if (!is_object($av)) {
                 $unfilledAttributes[] = $uak;
             }
         }
     }
     if ($this->post('completePartialProfile')) {
         foreach ($unfilledAttributes as $uak) {
             $e1 = $uak->validateAttributeForm();
             if ($e1 == false) {
                 $this->error->add(t('The field "%s" is required', $uak->getAttributeKeyName()));
             } else {
                 if ($e1 instanceof ValidationErrorHelper) {
                     $this->error->add($e1);
                 }
             }
         }
         if (!$this->error->has()) {
             // the user has needed to complete a partial profile, and they have done so,
             // and they have no errors. So we save our profile data against the account.
             foreach ($unfilledAttributes as $uak) {
                 $uak->saveAttributeForm($ui);
                 $unfilledAttributes = array();
             }
         }
     }
     if (count($unfilledAttributes) > 0) {
         $u->logout();
         $this->set('invalidRegistrationFields', true);
         $this->set('unfilledAttributes', $unfilledAttributes);
     }
     $txt = Loader::helper('text');
     $rcID = $this->post('rcID');
     $nh = Loader::helper('validation/numbers');
     //set redirect url
     if ($nh->integer($rcID)) {
         $nh = Loader::helper('navigation');
         $rc = Page::getByID($rcID);
         $url = $nh->getLinkToCollection($rc, true);
         $loginData['redirectURL'] = $url;
     } elseif (strlen($rcID)) {
         $rcID = trim($rcID, '/');
         $nc2 = Page::getByPath('/' . $rcID);
         if (is_object($nc2) && !$nc2->isError()) {
             $loginData['redirectURL'] = BASE_URL . DIR_REL . '/' . DISPATCHER_FILENAME . '/' . $rcID;
         }
     }
     /*
     //full page login redirect (non-ajax login)
     if( strlen($loginData['redirectURL']) && $_REQUEST['format']!='JSON' ){ 
     	header('Location: ' . $loginData['redirectURL']);
     	exit;	
     }
     */
     $dash = Page::getByPath("/dashboard", "RECENT");
     $dbp = new Permissions($dash);
     Events::fire('on_user_login', $this);
     //End JSON Login
     if ($_REQUEST['format'] == 'JSON') {
         return $loginData;
     }
     //should administrator be redirected to dashboard?  defaults to yes if not set.
     $adminToDash = intval(Config::get('LOGIN_ADMIN_TO_DASHBOARD'));
     //Full page login, standard redirection
     $u = new User();
     // added for the required registration attribute change above. We recalc the user and make sure they're still logged in
     if ($u->isRegistered()) {
         if ($u->config('NEWSFLOW_LAST_VIEWED') == 'FIRSTRUN') {
             $u->saveConfig('NEWSFLOW_LAST_VIEWED', 0);
         }
         if ($loginData['redirectURL']) {
             //make double secretly sure there's no caching going on
             header("Cache-Control: no-store, no-cache, must-revalidate");
             header("Pragma: no-cache");
             header('Expires: Fri, 30 Oct 1998 14:19:41 GMT');
             //in the past
             $this->externalRedirect($loginData['redirectURL']);
         } else {
             if ($dbp->canRead() && $adminToDash) {
                 $this->redirect('/dashboard');
             } else {
                 //options set in dashboard/users/registration
                 $login_redirect_cid = intval(Config::get('LOGIN_REDIRECT_CID'));
                 $login_redirect_mode = Config::get('LOGIN_REDIRECT');
                 //redirect to user profile
                 if ($login_redirect_mode == 'PROFILE' && ENABLE_USER_PROFILES) {
                     $this->redirect('/profile/', $u->uID);
                     //redirect to custom page
                 } elseif ($login_redirect_mode == 'CUSTOM' && $login_redirect_cid > 0) {
                     $redirectTarget = Page::getByID($login_redirect_cid);
                     if (intval($redirectTarget->cID) > 0) {
                         $this->redirect($redirectTarget->getCollectionPath());
                     } else {
                         $this->redirect('/');
                     }
                     //redirect home
                 } else {
                     $this->redirect('/');
                 }
             }
         }
     }
 }
コード例 #30
0
    public function removeFileFromSet($f_id)
    {
        if (is_object($f_id)) {
            $f_id = $f_id->fID;
        }
        $db = Loader::db();
        $db->Execute('DELETE FROM FileSetFiles 
			WHERE fID = ? 
			AND   fsID = ?', array($f_id, $this->getFileSetID()));
        Events::fire('on_file_removed_from_set', $f_id, $this->getFileSetID());
    }