/** * Get options for dropdown boxes. * @param string $name Name of options to return, ie: 'columns', 'type', 'status' * @param mixed $parent Parent name/ID of options to return if data is in hierarchical format. (ie: Province) * @return array */ function getOptions($name, $parent = NULL) { if ($name == 'columns' and (!$this->getPermissionObject()->Check('recurring_schedule_template', 'enabled') or !($this->getPermissionObject()->Check('recurring_schedule_template', 'view') or $this->getPermissionObject()->Check('recurring_schedule_template', 'view_own') or $this->getPermissionObject()->Check('recurring_schedule_template', 'view_child')))) { $name = 'list_columns'; } return parent::getOptions($name, $parent); }
/** * Get options for dropdown boxes. * @param string $name Name of options to return, ie: 'columns', 'type', 'status' * @param mixed $parent Parent name/ID of options to return if data is in hierarchical format. (ie: Province) * @return array */ function getOptions($name, $parent = NULL) { if ($name == 'columns' and (!$this->getPermissionObject()->Check('punch', 'enabled') or !($this->getPermissionObject()->Check('punch', 'view') or $this->getPermissionObject()->Check('punch', 'view_child')))) { $name = 'list_columns'; } return parent::getOptions($name, $parent); }
/** * Get options for dropdown boxes. * @param string $name Name of options to return, ie: 'columns', 'type', 'status' * @param mixed $parent Parent name/ID of options to return if data is in hierarchical format. (ie: Province) * @return array */ function getOptions($name, $parent = NULL) { if ($name == 'columns') { $name = 'list_columns'; } return parent::getOptions($name, $parent); }
/** * Route the request and display the value */ public function route() { try { $obj = APIFactory::init($this->parsed_path[0]); echo $this->getAction($obj, $this->parsed_path); } catch (UndefinedActionException $e) { echo $e->getMessage(); } catch (Exception $e) { echo $e->getMessage(); } }
/** * @param Localizer $locator */ public function __construct($locale) { $this->_view = \Xily\Bean::create($locale->replace(file_get_contents(MODULE_DIR . 'holidays' . DIRECTORY_SEPARATOR . 'holidays.xml'))); $api = APIFactory::get('domain'); $xmlFilterDomain = $this->_view->getNodeById('selFilterDomain'); if ($xmlFilterDomain) { $xmlFilterDomain->addChild(new \Xily\Bean('option', '--- ' . ucfirst($locale->get('common.all')) . ' ---', array('value' => ''))); foreach ($api->do_list() as $arrDomain) { $xmlFilterDomain->addChild(new \Xily\Bean('option', $arrDomain['Name'], array('value' => $arrDomain['Id']))); } } }
/** * Get options for dropdown boxes. * @param string $name Name of options to return, ie: 'columns', 'type', 'status' * @param mixed $parent Parent name/ID of options to return if data is in hierarchical format. (ie: Province) * @return array */ function getOptions($name, $parent = NULL) { if ($name == 'user_columns') { $uf = TTnew('UserFactory'); if ($this->getPermissionObject()->Check('user', 'enabled') and $this->getPermissionObject()->Check('user', 'view')) { $retarr = $uf->getOptions('columns'); } elseif ($this->getPermissionObject()->Check('user', 'enabled') and $this->getPermissionObject()->Check('user', 'view_child')) { $retarr = $uf->getOptions('user_child_secure_columns'); } else { $retarr = $uf->getOptions('user_secure_columns'); } return $retarr; } return parent::getOptions($name, $parent); }
public function __construct() { parent::__construct(); //Make sure parent constructor is always called. //When APIImport()->getImportObjects() is called directly, there won't be a main class to call. if (isset($this->main_class) and $this->main_class != '') { $this->import_obj = new $this->main_class(); $this->import_obj->company_id = $this->getCurrentCompanyObject()->getID(); $this->import_obj->user_id = $this->getCurrentUserObject()->getID(); Debug::Text('Setting main class: ' . $this->main_class . ' Company ID: ' . $this->import_obj->company_id, __FILE__, __LINE__, __METHOD__, 10); } else { Debug::Text('NOT Setting main class... Company ID: ' . $this->getCurrentCompanyObject()->getID(), __FILE__, __LINE__, __METHOD__, 10); } return TRUE; }
public function __construct() { parent::__construct(); //Make sure parent constructor is always called. //$company_obj = $this->getCurrentCompanyObject(); //$user_obj = $this->getCurrentUserObject(); //if ( isset($this->main_class) AND class_exists( $this->main_class, TRUE ) == TRUE ) { //$report_obj = new $this->main_class; $report_obj = TTNew($this->main_class); //Allow plugins to work with reports. $report_obj->setUserObject($this->getCurrentUserObject()); $report_obj->setPermissionObject($this->getPermissionObject()); $this->setMainClassObject($report_obj); //} return TRUE; }
public function __construct() { parent::__construct(); //Make sure parent constructor is always called. return TRUE; }
function PermissionDenied($result = FALSE, $description = 'Permission Denied') { if ($result !== TRUE) { Debug::Text('Permission Denied! Description: ' . $description, __FILE__, __LINE__, __METHOD__, 10); return APIFactory::returnHandler(FALSE, 'PERMISSION', $description); } return TRUE; }
/** * @return Authenticator */ public static function getAuthenticator() { if (self::$authenticator === null) { self::$authenticator = new Authenticator(); $cookieSalt = \Xily\Config::get('app.salt', 'string', ''); if ((string) $cookieSalt !== '') { self::$authenticator->salt = $cookieSalt; } } return self::$authenticator; }
protected function _API($elem) { $name = strtolower($elem['NAME']); $command = strtolower($elem['DO']); $callId = $name . '.' . $command; if ((string) $name === '' or (string) $command === '') { throw new Exception('iXML: <api> tag must specify non-empty "name" and "do" attributes.'); } elseif (isset(self::$apiCallStack[$callId])) { throw new Exception('iXML: Cannot recursively call API function "' . $callId . '".'); } $result = null; // Push API call self::$apiCallStack[$callId] = true; try { //$parameters = $this->toApiParameters($this->runParams($elem)); $parameters = array(); foreach ($this->runParams($elem) as $paramName => $paramData) { $parameters[$paramName] = \Zeyon\iXml::export($paramData); } $result = APIFactory::get($name)->dispatch($command, $parameters); if ($elem['VAR']) { $this->setVar($elem['VAR'], \Zeyon\iXml::import($result)); } } catch (Exception $e) { unset(self::$apiCallStack[$callId]); throw $e; } unset(self::$apiCallStack[$callId]); return json_encode($result); }
PluginPeer::registerEvent($entity, $event); } } } try { registerPluginEvents($pluginEvents); $userAuthenticated = APIFactory::getAuthenticator()->authUser(true, true, isset($_REQUEST['autologin']) && $_REQUEST['autologin'] == true); $user = APIFactory::getAuthenticator()->getUser(); PluginPeer::setAuthenticatedUser($user); if (isset($_REQUEST['do'])) { /* PERFORM THE API CALL -------------------------------------------------------------------- */ $api = null; try { $apiName = array_key_exists('api', $_REQUEST) ? strtolower($_REQUEST['api']) : API_DEFAULT; $api = APIFactory::get($apiName); $api->run(); } catch (Exception $e) { if ($e instanceof APIPermissionDeniedException and !empty($_REQUEST['inline'])) { HTTP::forwardTo($_SERVER['SCRIPT_NAME'] . '?view=login' . '&return=' . urlencode($_SERVER['REQUEST_URI']) . '&' . Form::getTokenName() . '=' . urlencode(Form::getToken('loginreturn'))); } else { header('Content-Type: application/json; charset=utf-8'); if ($api instanceof API) { $res = $api->exceptionToResult($e); } else { $res = array('error' => $e->getMessage()); if (isset($_REQUEST['debug'])) { $res['trace'] = $e->getTrace(); } } echo json_encode($res);
/** * @param locator $locator */ public function __construct($locale) { APIFactory::getAuthenticator()->setUserSession(); $this->_view = \Xily\Bean::create($locale->replace(file_get_contents(VIEW_DIR . 'login.xml'))); }
public function buildHeaderMenu() { global $locale; $html = ' <div class="navbar navbar-fixed-top"> <div class="navbar-inner"> <div class="container" style="width: auto;"> <a class="brand" href="' . buildLink('clockings') . '" id="loader"><img src="assets/img/logo.png" alt="tymio" /></a>'; // Workaround with catching the exception but // more pretty would be a function like API->isAuthenticated() // instead of call complete authentication again (done in index.php) try { $authenticator = \APIFactory::getAuthenticator(); $user = $authenticator->authUser(); if ($user !== null) { $email = strtolower($user->getEmail()); $html .= '<div class="nav-collapse">' . '<ul class="nav">' . $locale->replace($this->compileMenu(Xml::create(APP_DIR . ($user->isAdmin() ? 'menu-admin.xml' : 'menu.xml'), 1))) . '</ul>' . '</div>' . '<div id="login" style="background-image: url(\'https://secure.gravatar.com/avatar/' . md5($email) . '?s=28&d=mm\')">' . 'Logged in as ' . $user->getFQN() . '. <a class="btn btn-mini" href="' . buildLink('logout') . '"><i class="icon icon-off"></i> Logout</a>'; } else { throw new Exception(); } } catch (Exception $e) { $html .= '<div id="login" class="loggedout">Not logged in <a class="btn btn-success btn-mini" href="' . buildLink('login') . '"><i class="icon icon-white icon-lock"></i> Login</a>'; } $html .= ' </div> <ul class="nav pull-right"> <li class="divider-vertical"></li> </ul> </div> </div> </div>'; return $html; }
<?php require_once "php/class.apifactory.php"; require_once "php/class.cache.php"; $api = new APIFactory(); $api->add_hooker('AF_Cache'); $api->fromJSON("./apis/mobicart.json"); $api->api_key = 1234; $api->user_name = '*****@*****.**'; print_r($api->metafields());