当前位置: 首页>>代码示例>>PHP>>正文


PHP Author::get方法代码示例

本文整理汇总了PHP中Author::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Author::get方法的具体用法?PHP Author::get怎么用?PHP Author::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Author的用法示例。


在下文中一共展示了Author::get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: login

 /**
  * Attempts to log an Author in given a username and password.
  * If the password is not hashed, it will be hashed using the sha1
  * algorithm. The username and password will be sanitized before
  * being used to query the Database. If an Author is found, they
  * will be logged in and the sanitized username and password (also hashed)
  * will be saved as values in the `$Cookie`.
  *
  * @see toolkit.Cryptography#hash()
  * @throws DatabaseException
  * @param string $username
  *  The Author's username. This will be sanitized before use.
  * @param string $password
  *  The Author's password. This will be sanitized and then hashed before use
  * @param boolean $isHash
  *  If the password provided is already hashed, setting this parameter to
  *  true will stop it becoming rehashed. By default it is false.
  * @return boolean
  *  True if the Author was logged in, false otherwise
  */
 public static function login($username, $password, $isHash = false)
 {
     $username = trim(self::Database()->cleanValue($username));
     $password = trim(self::Database()->cleanValue($password));
     if (strlen($username) > 0 && strlen($password) > 0) {
         $author = AuthorManager::fetch('id', 'ASC', 1, null, sprintf("`username` = '%s'", $username));
         if (!empty($author) && Cryptography::compare($password, current($author)->get('password'), $isHash)) {
             self::$Author = current($author);
             // Only migrate hashes if there is no update available as the update might change the tbl_authors table.
             if (self::isUpgradeAvailable() === false && Cryptography::requiresMigration(self::$Author->get('password'))) {
                 self::$Author->set('password', Cryptography::hash($password));
                 self::Database()->update(array('password' => self::$Author->get('password')), 'tbl_authors', sprintf(" `id` = %d", self::$Author->get('id')));
             }
             self::$Cookie->set('username', $username);
             self::$Cookie->set('pass', self::$Author->get('password'));
             self::Database()->update(array('last_seen' => DateTimeObj::get('Y-m-d H:i:s')), 'tbl_authors', sprintf(" `id` = %d", self::$Author->get('id')));
             // Only set custom author language in the backend
             if (class_exists('Administration', false)) {
                 Lang::set(self::$Author->get('language'));
             }
             return true;
         }
     }
     return false;
 }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:45,代码来源:class.symphony.php

示例2: isLoggedIn

 /**
  * This function determines whether an there is a currently logged in
  * Author for Symphony by using the `$Cookie`'s username
  * and password. If an Author is found, they will be logged in, otherwise
  * the `$Cookie` will be destroyed.
  *
  * @see core.Cookie#expire()
  */
 public function isLoggedIn()
 {
     // Ensures that we're in the real world.. Also reduces three queries from database
     // We must return true otherwise exceptions are not shown
     if (is_null(self::$_instance)) {
         return true;
     }
     if ($this->Author) {
         return true;
     } else {
         $username = self::Database()->cleanValue($this->Cookie->get('username'));
         $password = self::Database()->cleanValue($this->Cookie->get('pass'));
         if (strlen(trim($username)) > 0 && strlen(trim($password)) > 0) {
             $author = AuthorManager::fetch('id', 'ASC', 1, null, sprintf("\n\t\t\t\t\t\t\t`username` = '%s'\n\t\t\t\t\t\t", $username));
             if (!empty($author) && Cryptography::compare($password, current($author)->get('password'), true)) {
                 $this->Author = current($author);
                 self::Database()->update(array('last_seen' => DateTimeObj::get('Y-m-d H:i:s')), 'tbl_authors', sprintf(" `id` = %d", $this->Author->get('id')));
                 // Only set custom author language in the backend
                 if (class_exists('Administration')) {
                     Lang::set($this->Author->get('language'));
                 }
                 return true;
             }
         }
         $this->Cookie->expire();
         return false;
     }
 }
开发者ID:readona,项目名称:symphonyno5,代码行数:36,代码来源:class.symphony.php

示例3: isLoggedIn

 /**
  * This function determines whether an there is a currently logged in
  * Author for Symphony by using the `$Cookie`'s username
  * and password. If an Author is found, they will be logged in, otherwise
  * the `$Cookie` will be destroyed.
  *
  * @see core.Cookie#expire()
  */
 public function isLoggedIn()
 {
     // Ensures that we're in the real world.. Also reduces three queries from database
     // We must return true otherwise exceptions are not shown
     if (is_null(self::$_instance)) {
         return true;
     }
     if ($this->Author) {
         return true;
     } else {
         $username = self::$Database->cleanValue($this->Cookie->get('username'));
         $password = self::$Database->cleanValue($this->Cookie->get('pass'));
         if (strlen(trim($username)) > 0 && strlen(trim($password)) > 0) {
             $id = self::$Database->fetchVar('id', 0, "SELECT `id` FROM `tbl_authors` WHERE `username` = '{$username}' AND `password` = '{$password}' LIMIT 1");
             if ($id) {
                 self::$Database->update(array('last_seen' => DateTimeObj::get('Y-m-d H:i:s')), 'tbl_authors', " `id` = '{$id}'");
                 $this->Author = AuthorManager::fetchByID($id);
                 Lang::set($this->Author->get('language'));
                 return true;
             }
         }
         $this->Cookie->expire();
         return false;
     }
 }
开发者ID:scottkf,项目名称:keepflippin--on-symphony,代码行数:33,代码来源:class.symphony.php

示例4: show

 public function show(SS_HTTPRequest $request)
 {
     $author = Author::get()->byID($request->param('ID'));
     if (!$author) {
         return $this->httpError(404, 'That author could not be found');
     }
     return array('Author' => $author);
 }
开发者ID:krissihall,项目名称:sm_ss,代码行数:8,代码来源:Authors.php

示例5: function

    if (!isset($authorId)) {
        $app->abort(404, 'Author has to be selected. Go back and select author');
    }
    $title = $request->request->get('title');
    $message = $request->request->get('message');
    $postModel->set($title, $message, $authorId);
    return $app->redirect($app["url_generator"]->generate("post_index"));
})->bind('post_add');
$app->get('/authors', function () use($app) {
    $authorModel = new Author($app['db']);
    $authorsToDisplay = $authorModel->getAll();
    return $app['twig']->render('author_index.html.twig', array('authors' => $authorsToDisplay));
})->bind('author_index');
$app->get('/author/{author_id}', function ($author_id) use($app) {
    $authorModel = new Author($app['db']);
    $authorToDisplay = $authorModel->get($author_id);
    if (!$authorToDisplay) {
        $app->abort(404, 'The article could not be found');
    }
    return $app['twig']->render('author_single.html.twig', array('author' => $authorToDisplay));
})->assert('author_id', '\\d+')->bind('author_single');
$app->get('/author/new', function () use($app) {
    return $app['twig']->render('author_new.html.twig');
})->bind('author_new');
$app->post('/author/add', function (Request $request) use($app) {
    $authorModel = new Author($app['db']);
    $name = $request->request->get('name');
    $authorModel->setName($name);
    return $app->redirect($app["url_generator"]->generate("author_index"));
})->bind('author_add');
// This should be the last line
开发者ID:marchage,项目名称:phpsilexblog,代码行数:31,代码来源:index.php

示例6: __form

 public function __form()
 {
     require_once TOOLKIT . '/class.field.php';
     // Handle unknown context
     if (!in_array($this->_context[0], array('new', 'edit'))) {
         Administration::instance()->errorPageNotFound();
     }
     if ($this->_context[0] == 'new' && !Administration::instance()->Author->isDeveloper()) {
         Administration::instance()->customError(__('Access Denied'), __('You are not authorised to access this page.'));
     }
     if (isset($this->_context[2])) {
         switch ($this->_context[2]) {
             case 'saved':
                 $this->pageAlert(__('Author updated at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/system/authors/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/system/authors/" accesskey="a">' . __('View all Authors') . '</a>', Alert::SUCCESS);
                 break;
             case 'created':
                 $this->pageAlert(__('Author created at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/system/authors/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/system/authors/" accesskey="a">' . __('View all Authors') . '</a>', Alert::SUCCESS);
                 break;
         }
     }
     $this->setPageType('form');
     $isOwner = false;
     if (isset($_POST['fields'])) {
         $author = $this->_Author;
     } else {
         if ($this->_context[0] == 'edit') {
             if (!($author_id = $this->_context[1])) {
                 redirect(SYMPHONY_URL . '/system/authors/');
             }
             if (!($author = AuthorManager::fetchByID($author_id))) {
                 Administration::instance()->customError(__('Author not found'), __('The author profile you requested does not exist.'));
             }
         } else {
             $author = new Author();
         }
     }
     if ($this->_context[0] == 'edit' && $author->get('id') == Administration::instance()->Author->get('id')) {
         $isOwner = true;
     }
     if ($this->_context[0] == 'edit' && !$isOwner && !Administration::instance()->Author->isDeveloper()) {
         Administration::instance()->customError(__('Access Denied'), __('You are not authorised to edit other authors.'));
     }
     $this->setTitle(__($this->_context[0] == 'new' ? '%2$s &ndash; %3$s' : '%1$s &ndash; %2$s &ndash; %3$s', array($author->getFullName(), __('Authors'), __('Symphony'))));
     $this->appendSubheading($this->_context[0] == 'new' ? __('Untitled') : $author->getFullName());
     $this->insertBreadcrumbs(array(Widget::Anchor(__('Authors'), SYMPHONY_URL . '/system/authors/')));
     // Essentials
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', __('Essentials')));
     $div = new XMLElement('div');
     $div->setAttribute('class', 'two columns');
     $label = Widget::Label(__('First Name'), NULL, 'column');
     $label->appendChild(Widget::Input('fields[first_name]', $author->get('first_name')));
     $div->appendChild(isset($this->_errors['first_name']) ? Widget::Error($label, $this->_errors['first_name']) : $label);
     $label = Widget::Label(__('Last Name'), NULL, 'column');
     $label->appendChild(Widget::Input('fields[last_name]', $author->get('last_name')));
     $div->appendChild(isset($this->_errors['last_name']) ? Widget::Error($label, $this->_errors['last_name']) : $label);
     $group->appendChild($div);
     $label = Widget::Label(__('Email Address'));
     $label->appendChild(Widget::Input('fields[email]', $author->get('email')));
     $group->appendChild(isset($this->_errors['email']) ? Widget::Error($label, $this->_errors['email']) : $label);
     $this->Form->appendChild($group);
     // Login Details
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', __('Login Details')));
     $div = new XMLElement('div');
     $label = Widget::Label(__('Username'));
     $label->appendChild(Widget::Input('fields[username]', $author->get('username')));
     $div->appendChild(isset($this->_errors['username']) ? Widget::Error($label, $this->_errors['username']) : $label);
     // Only developers can change the user type. Primary account should NOT be able to change this
     if (Administration::instance()->Author->isDeveloper() && !$author->isPrimaryAccount()) {
         // Create columns
         $div->setAttribute('class', 'two columns');
         $label->setAttribute('class', 'column');
         // User type
         $label = Widget::Label(__('User Type'), NULL, 'column');
         $options = array(array('author', false, __('Author')), array('developer', $author->isDeveloper(), __('Developer')));
         $label->appendChild(Widget::Select('fields[user_type]', $options));
         $div->appendChild($label);
     }
     $group->appendChild($div);
     // Password
     $fieldset = new XMLElement('fieldset', NULL, array('class' => 'two columns', 'id' => 'password'));
     $legend = new XMLElement('legend', __('Password'));
     $help = new XMLElement('i', __('Leave password fields blank to keep the current password'));
     $fieldset->appendChild($legend);
     $fieldset->appendChild($help);
     // Password reset
     if ($this->_context[0] == 'edit' && (!Administration::instance()->Author->isDeveloper() || $isOwner === true)) {
         $fieldset->setAttribute('class', 'three columns');
         $label = Widget::Label(NULL, NULL, 'column');
         $label->appendChild(Widget::Input('fields[old-password]', NULL, 'password', array('placeholder' => __('Old Password'))));
         $fieldset->appendChild(isset($this->_errors['old-password']) ? Widget::Error($label, $this->_errors['password']) : $label);
     }
     // New password
     $callback = Administration::instance()->getPageCallback();
     $placeholder = $callback['context'][0] == 'edit' ? __('New Password') : __('Password');
     $label = Widget::Label(NULL, NULL, 'column');
     $label->appendChild(Widget::Input('fields[password]', NULL, 'password', array('placeholder' => $placeholder)));
//.........这里部分代码省略.........
开发者ID:bauhouse,项目名称:Piano-Sonata,代码行数:101,代码来源:content.systemauthors.php

示例7: appendFormattedElement

 public function appendFormattedElement(&$wrapper, $data, $encode = false)
 {
     if (!is_array($data['author_id'])) {
         $data['author_id'] = array($data['author_id']);
     }
     $list = new XMLElement($this->get('element_name'));
     foreach ($data['author_id'] as $author_id) {
         $author = new Author($author_id);
         $list->appendChild(new XMLElement('item', $author->getFullName(), array('id' => (string) $author->get('id'), 'username' => General::sanitize($author->get('username')))));
     }
     $wrapper->appendChild($list);
 }
开发者ID:bauhouse,项目名称:sym-form-builder,代码行数:12,代码来源:field.author.php

示例8: Author

 function authors_get()
 {
     if (!$this->get('search')) {
         $this->response(NULL, 400);
     }
     $authors = new Author();
     $authors->like('name', $this->get('search'));
     $authors->order_by('name', 'asc');
     $authors->limit(5);
     $authors->get();
     if ($authors->exists()) {
         foreach ($authors as $author) {
             $authors_array[] = $author->name;
         }
         $this->response($authors_array, 200);
         // 200 being the HTTP response code
     } else {
         $this->response(array('error' => 'Authors could not be found'), 404);
     }
 }
开发者ID:TetsujinOni,项目名称:PFS-Scenariotracker,代码行数:20,代码来源:V1.php

示例9: switch

 function __form()
 {
     require_once TOOLKIT . '/class.field.php';
     ## Handle unknow context
     if (!in_array($this->_context[0], array('new', 'edit'))) {
         $this->_Parent->errorPageNotFound();
     }
     if ($this->_context[0] == 'new' && !Administration::instance()->Author->isDeveloper()) {
         $this->_Parent->customError(E_USER_ERROR, 'Access Denied', 'You are not authorised to access this page.');
     }
     if (isset($this->_context[2])) {
         switch ($this->_context[2]) {
             case 'saved':
                 $this->pageAlert(__('Author updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Authors</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), URL . '/symphony/system/authors/new/', URL . '/symphony/system/authors/')), Alert::SUCCESS);
                 break;
             case 'created':
                 $this->pageAlert(__('Author created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Authors</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), URL . '/symphony/system/authors/new/', URL . '/symphony/system/authors/')), Alert::SUCCESS);
                 break;
         }
     }
     $this->setPageType('form');
     $isOwner = false;
     if (isset($_POST['fields'])) {
         $author = $this->_Author;
     } elseif ($this->_context[0] == 'edit') {
         if (!($author_id = $this->_context[1])) {
             redirect(URL . '/symphony/system/authors/');
         }
         if (!($author = AuthorManager::fetchByID($author_id))) {
             $this->_Parent->customError(E_USER_ERROR, 'Author not found', 'The author profile you requested does not exist.');
         }
     } else {
         $author = new Author();
     }
     if ($this->_context[0] == 'edit' && $author->get('id') == Administration::instance()->Author->get('id')) {
         $isOwner = true;
     }
     if ($this->_context[0] == 'edit' && !$isOwner && !Administration::instance()->Author->isDeveloper()) {
         $this->_Parent->customError(E_USER_ERROR, 'Access Denied', 'You are not authorised to edit other authors.');
     }
     $this->setTitle(__($this->_context[0] == 'new' ? '%1$s &ndash; %2$s &ndash; %3$s' : '%1$s &ndash; %2$s', array(__('Symphony'), __('Authors'), $author->getFullName())));
     $this->appendSubheading($this->_context[0] == 'new' ? __('Untitled') : $author->getFullName());
     ### Essentials ###
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', __('Essentials')));
     $div = new XMLElement('div');
     $div->setAttribute('class', 'group');
     $label = Widget::Label(__('First Name'));
     $label->appendChild(Widget::Input('fields[first_name]', $author->get('first_name')));
     $div->appendChild(isset($this->_errors['first_name']) ? $this->wrapFormElementWithError($label, $this->_errors['first_name']) : $label);
     $label = Widget::Label(__('Last Name'));
     $label->appendChild(Widget::Input('fields[last_name]', $author->get('last_name')));
     $div->appendChild(isset($this->_errors['last_name']) ? $this->wrapFormElementWithError($label, $this->_errors['last_name']) : $label);
     $group->appendChild($div);
     $label = Widget::Label(__('Email Address'));
     $label->appendChild(Widget::Input('fields[email]', $author->get('email')));
     $group->appendChild(isset($this->_errors['email']) ? $this->wrapFormElementWithError($label, $this->_errors['email']) : $label);
     $this->Form->appendChild($group);
     ###
     ### Login Details ###
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', __('Login Details')));
     $div = new XMLElement('div');
     $div->setAttribute('class', 'group');
     $label = Widget::Label(__('Username'));
     $label->appendChild(Widget::Input('fields[username]', $author->get('username'), NULL));
     $div->appendChild(isset($this->_errors['username']) ? $this->wrapFormElementWithError($label, $this->_errors['username']) : $label);
     // Only developers can change the user type. Primary account should NOT be able to change this
     if (Administration::instance()->Author->isDeveloper() && !$author->isPrimaryAccount()) {
         $label = Widget::Label(__('User Type'));
         $options = array(array('author', false, __('Author')), array('developer', $author->isDeveloper(), __('Developer')));
         $label->appendChild(Widget::Select('fields[user_type]', $options));
         $div->appendChild($label);
     }
     $group->appendChild($div);
     $div = new XMLElement('div', NULL, array('class' => 'group'));
     if ($this->_context[0] == 'edit') {
         $div->setAttribute('id', 'change-password');
         if (!Administration::instance()->Author->isDeveloper() || $isOwner === true) {
             $div->setAttribute('class', 'triple group');
             $label = Widget::Label(__('Old Password'));
             if (isset($this->_errors['old-password'])) {
                 $label->setAttributeArray(array('class' => 'contains-error', 'title' => $this->_errors['old-password']));
             }
             $label->appendChild(Widget::Input('fields[old-password]', NULL, 'password'));
             $div->appendChild(isset($this->_errors['old-password']) ? $this->wrapFormElementWithError($label, $this->_errors['old-password']) : $label);
         }
     }
     $label = Widget::Label($this->_context[0] == 'edit' ? __('New Password') : __('Password'));
     $label->appendChild(Widget::Input('fields[password]', NULL, 'password'));
     $div->appendChild(isset($this->_errors['password']) ? $this->wrapFormElementWithError($label, $this->_errors['password']) : $label);
     $label = Widget::Label($this->_context[0] == 'edit' ? __('Confirm New Password') : __('Confirm Password'));
     if (isset($this->_errors['password-confirmation'])) {
         $label->setAttributeArray(array('class' => 'contains-error', 'title' => $this->_errors['password-confirmation']));
     }
     $label->appendChild(Widget::Input('fields[password-confirmation]', NULL, 'password'));
     $div->appendChild($label);
     $group->appendChild($div);
//.........这里部分代码省略.........
开发者ID:njmcgee,项目名称:njmcgee2,代码行数:101,代码来源:content.systemauthors.php

示例10: fetchByID

 /**
  * Returns Author's that match the provided ID's with the option to sort or limit the
  * output. This function will search the `AuthorManager::$_pool` for Authors first before
  * querying `tbl_authors`
  *
  * @param integer|array $id
  *	A single ID or an array of ID's
  * @param string $sortby
  *	The field to sort the authors by, defaults to 'id'
  * @param string $sortdirection
  *	Available values of ASC (Ascending) or DESC (Descending), which refer to the
  *	sort order for the query. Defaults to ASC (Ascending)
  * @param integer $limit
  *	The number of rows to return
  * @param integer $start
  *	The offset start point for limiting, maps to the LIMIT {x}, {y} MySQL functionality
  * @return mixed
  *	If `$id` was an integer, the result will be an Author object, otherwise an array of
  *	Author objects will be returned. If no Authors are found, or no `$id` is given null is returned.
  */
 public static function fetchByID($id, $sortby = 'id', $sortdirection = 'ASC', $limit = null, $start = null)
 {
     $return_single = false;
     if (!is_array($id)) {
         $return_single = true;
         $id = array($id);
     }
     if (empty($id)) {
         return null;
     }
     $authors = array();
     $pooled_authors = array();
     // Get all the Author ID's that are already in `self::$_pool`
     $pooled_authors = array_intersect($id, array_keys(self::$_pool));
     foreach ($pooled_authors as $pool_author) {
         $authors[] = self::$_pool[$pool_author];
     }
     // Get all the Author ID's that are not already stored in `self::$_pool`
     $id = array_diff($id, array_keys(self::$_pool));
     if (empty($id)) {
         return $return_single ? $authors[0] : $authors;
     }
     $records = Symphony::Database()->fetch(sprintf("\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM `tbl_authors`\n\t\t\t\t\tWHERE `id` IN (%d)\n\t\t\t\t\tORDER BY %s %s\n\t\t\t\t\t%s %s\n\t\t\t\t", implode(",", $id), $sortby, $sortdirection, $limit ? "LIMIT " . $limit : '', $start && $limit ? ', ' . $start : ''));
     if (!is_array($records) || empty($records)) {
         return $return_single ? $authors[0] : $authors;
     }
     foreach ($records as $row) {
         $author = new Author();
         foreach ($row as $field => $val) {
             $author->set($field, $val);
         }
         self::$_pool[$author->get('id')] = $author;
         $authors[] = $author;
     }
     return $return_single ? $authors[0] : $authors;
 }
开发者ID:rainerborene,项目名称:symphony-2,代码行数:56,代码来源:class.authormanager.php

示例11: fetchByID

 /**
  * Returns Author's that match the provided ID's with the option to
  * sort or limit the output. This function will search the
  * `AuthorManager::$_pool` for Authors first before querying `tbl_authors`
  *
  * @param integer|array $id
  *  A single ID or an array of ID's
  * @throws DatabaseException
  * @return mixed
  *  If `$id` is an integer, the result will be an Author object,
  *  otherwise an array of Author objects will be returned. If no
  *  Authors are found, or no `$id` is given, `null` is returned.
  */
 public static function fetchByID($id)
 {
     $return_single = false;
     if (is_null($id)) {
         return null;
     }
     if (!is_array($id)) {
         $return_single = true;
         $id = array((int) $id);
     }
     if (empty($id)) {
         return null;
     }
     // Get all the Author ID's that are already in `self::$_pool`
     $authors = array();
     $pooled_authors = array_intersect($id, array_keys(self::$_pool));
     foreach ($pooled_authors as $pool_author) {
         $authors[] = self::$_pool[$pool_author];
     }
     // Get all the Author ID's that are not already stored in `self::$_pool`
     $id = array_diff($id, array_keys(self::$_pool));
     $id = array_filter($id);
     if (empty($id)) {
         return $return_single ? $authors[0] : $authors;
     }
     $records = Symphony::Database()->fetch(sprintf("SELECT *\n            FROM `tbl_authors`\n            WHERE `id` IN (%s)", implode(",", $id)));
     if (!is_array($records) || empty($records)) {
         return $return_single ? $authors[0] : $authors;
     }
     foreach ($records as $row) {
         $author = new Author();
         foreach ($row as $field => $val) {
             $author->set($field, $val);
         }
         self::$_pool[$author->get('id')] = $author;
         $authors[] = $author;
     }
     return $return_single ? $authors[0] : $authors;
 }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:52,代码来源:class.authormanager.php

示例12: detalhe

function detalhe($id)
{
    global $twig;
    $author = new Author();
    echo $twig->render('author_detail.html', array('author' => $author->get("id = {$id}")));
}
开发者ID:rfloriano,项目名称:rfloriano-treichel-bookstore,代码行数:6,代码来源:authors.php

示例13: userCanDoAction

 public function userCanDoAction($user, $entry, $action)
 {
     //DEFAULT RETURN VALUE IS TRUE
     $ret = true;
     //GRANT ALL PERMISSIONS TO THE AUTHOR
     $author = new Author();
     $author->clause('author_id', $entry->get('author_id'));
     $author->noForeign();
     $author_user_id = $author->get('user_id');
     if ($author_user_id != $user->id()) {
         //FIRST CHECK IF WE ARE EXCLUDED BASED ON ACCESS LEVEL
         $min_level = Application::user()->minAccessLevel();
         $check_entry = $entry->restrict();
         //IF THE ENTRY ACCESS ID IS GREATER THAN THE MIN LEVEL
         //OF THE CURRENT APP USER (0 IS ROOT LEVEL ACCESS)
         if ($access = $check_entry->fetchSingle('Access')) {
             $level = $access->get('access_level');
         } else {
             $level = 0;
         }
         if ($level >= $min_level) {
             if ($user->id()) {
                 $access = new EntryGroupAccess();
                 //NOW CHECK IF THERE IS GROUP ACCESS CONTROL FOR
                 //ANY GROUPS THIS USER IS A MEMBER OF
                 $user = $user->restrict();
                 $user->also('Group');
                 $access->clause('author_id', $entry->get('author_id'));
                 $access->clause('entry_id', $entry->get('entry_id'));
                 //IF THE USER IS IN ANY GROUPS
                 if ($groups = $user->fetch('Group')) {
                     $access->clause('group_id', $groups, Clause::IN);
                 } else {
                     $access->clause('group_id', 0);
                 }
                 //IF THERE WERE ACCESS ENTRIES FOR GROUPS THAT THIS USER IS IN
                 if ($entries = $access->fetch()) {
                     //LOOP THROUGH UNTIL WE FIND A GROUP THAT DIASALLOWS
                     //THEN STOP
                     foreach ($entries as $access_entry) {
                         if ($ret) {
                             $ret = $access_entry->get($action);
                         } else {
                             end($entries);
                         }
                     }
                 } else {
                     if ($action != LogbookAccess::VIEW) {
                         $ret = false;
                     }
                 }
             } else {
                 if ($action != LogbookAccess::VIEW) {
                     $ret = false;
                 }
             }
         } else {
             $ret = false;
         }
     }
     return $ret;
 }
开发者ID:k7n4n5t3w4rt,项目名称:SeeingSystem,代码行数:62,代码来源:logbook_access.class.php


注:本文中的Author::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。