Stores metadata in private settings rather than as ElggMetadata
상속: extends ElggObject
예제 #1
0
 /**
  * @see elgg_create_widget
  * @access private
  * @since 1.9.0
  */
 public function createWidget($owner_guid, $handler, $context, $access_id = null)
 {
     if (empty($owner_guid) || empty($handler) || !$this->validateType($handler)) {
         return false;
     }
     $owner = get_entity($owner_guid);
     if (!$owner) {
         return false;
     }
     $widget = new \ElggWidget();
     $widget->owner_guid = $owner_guid;
     $widget->container_guid = $owner_guid;
     // @todo - will this work for group widgets?
     if (isset($access_id)) {
         $widget->access_id = $access_id;
     } else {
         $widget->access_id = get_default_access();
     }
     if (!$widget->save()) {
         return false;
     }
     // private settings cannot be set until \ElggWidget saved
     $widget->handler = $handler;
     $widget->context = $context;
     return $widget->getGUID();
 }
예제 #2
0
 public function addWidget($section, $guid = null, $context = 'framework')
 {
     $widget = new ElggWidget($guid);
     $widget->title = $this->getSectionTitle($section);
     $widget->name = $this->getSectionName($section);
     $widget->owner_guid = $this->owner_guid;
     $widget->container_guid = $this->guid;
     $widget->handler = $this->get('handler');
     $widget->context = $context;
     $widget->section = $section;
     $widget->access_id = $this->access_id;
     if ($widget->save()) {
         $widget->move(1, 1);
     }
     return $widget;
 }
예제 #3
0
 public function canEdit($user_guid = 0)
 {
     $result = parent::canEdit($user_guid);
     if ($result && ($this->fixed && !elgg_is_admin_logged_in())) {
         $result = false;
     }
     return $result;
 }
예제 #4
0
/**
 * Add a new widget instance
 *
 * @param int    $entity_guid GUID of entity that owns this widget
 * @param string $handler     The handler for this widget
 * @param string $context     The page context for this widget
 * @param int    $order       The order to display this widget in
 * @param int    $column      The column to display this widget in (1, 2 or 3)
 * @param int    $access_id   If not specified, it is set to the default access level
 *
 * @return int|false Widget GUID or false on failure
 * @deprecated 1.8 use elgg_create_widget()
 */
function add_widget($entity_guid, $handler, $context, $order = 0, $column = 1, $access_id = null)
{
    elgg_deprecated_notice('add_widget has been deprecated for elgg_create_widget', 1.8);
    if (empty($entity_guid) || empty($context) || empty($handler) || !widget_type_exists($handler)) {
        return false;
    }
    if ($entity = get_entity($entity_guid)) {
        $widget = new ElggWidget();
        $widget->owner_guid = $entity_guid;
        $widget->container_guid = $entity_guid;
        if (isset($access_id)) {
            $widget->access_id = $access_id;
        } else {
            $widget->access_id = get_default_access();
        }
        $guid = $widget->save();
        // private settings cannot be set until ElggWidget saved
        $widget->handler = $handler;
        $widget->context = $context;
        $widget->column = $column;
        $widget->order = $order;
        return $guid;
    }
    return false;
}
예제 #5
0
 protected function initialise_attributes()
 {
     parent::initialise_attributes();
     $this->attributes['subtype'] = 'sticky_widget';
 }
/**
 * Add a new widget
 *
 * @param int $user_guid User GUID to associate this widget with
 * @param string $handler The handler for this widget
 * @param string $context The page context for this widget
 * @param int $order The order to display this widget in
 * @param int $column The column to display this widget in (1, 2 or 3)
 * @param int $access_id If not specified, it is set to the default access level
 * @return true|false Depending on success
 */
function add_widget($user_guid, $handler, $context, $order = 0, $column = 1, $access_id = null)
{
    if (empty($user_guid) || empty($context) || empty($handler) || !widget_type_exists($handler)) {
        return false;
    }
    if ($user = get_user($user_guid)) {
        $widget = new ElggWidget();
        $widget->owner_guid = $user_guid;
        $widget->container_guid = $user_guid;
        if (isset($access_id)) {
            $widget->access_id = $access_id;
        } else {
            $widget->access_id = get_default_access();
        }
        if (!$widget->save()) {
            return false;
        }
        $widget->handler = $handler;
        $widget->context = $context;
        $widget->column = $column;
        $widget->order = $order;
        // save_widget_location($widget, $order, $column);
        return true;
    }
    return false;
}