Пример #1
0
 /**
  * Get context widgets
  * @return array of IWidget
  */
 public function getWidgets()
 {
     if ($this->widgets === NULL) {
         $this->widgets = WidgetManager::GetWidgetsByContext($this);
     }
     return $this->widgets;
 }
Пример #2
0
 public function init()
 {
     if ($this->data === null) {
         throw new CException(Yii::t('zii', 'Please specify the "data" property.'));
     }
     if ($this->attributes === null) {
         if ($this->data instanceof CModel) {
             $attributes = WidgetManager::getVisibleColumns(get_class($this->data), $this->id);
             if ($attributes) {
                 $this->attributes = $attributes;
             } else {
                 $this->attributes = $this->data->attributeNames();
             }
         } else {
             if (is_array($this->data)) {
                 $this->attributes = array_keys($this->data);
             } else {
                 throw new CException(Yii::t('zii', 'Please specify the "attributes" property.'));
             }
         }
     }
     if ($this->nullDisplay === null) {
         $this->nullDisplay = '<span class="null">' . Yii::t('zii', 'Not set') . '</span>';
     }
     $this->htmlOptions['id'] = $this->getId();
     if ($this->baseScriptUrl === null) {
         $this->baseScriptUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.components.zii.assets')) . '/detailview';
     }
     $this->cssFile = $this->baseScriptUrl . '/styles.css';
     Yii::app()->getClientScript()->registerCssFile($this->cssFile);
 }
Пример #3
0
 public function testGetAvailable()
 {
     $widgets = WidgetManager::GetAvailable();
     $this->assertTrue(is_array($widgets));
     $this->assertGreaterThan(0, sizeof($widgets));
     foreach ($widgets as $widget) {
         $this->assertContains('IWidget', class_implements($widget));
     }
 }
Пример #4
0
    /**
     * @param string array $path
     */
    public function __construct($path)
    {
        $this->realpath = realpath($path);
        if ($this->realpath === FALSE || !is_file($this->realpath)) {
            throw new InvalidArgumentException("File '$this->path' not found.");
        }

        $filter = realpath(WWW_DIR . WidgetManager::ExtPath()) . DIR_SEP;
        $this->path = str_replace($filter, '', $this->realpath);
    }
Пример #5
0
    /**
     * Get path
     * @return string
     */
    public function getPath()
    {
	$cur_path = $this->m_data['path'];

	if (0 === strpos($cur_path, WWW_DIR)) {
	    return $cur_path;
	}

        return WWW_DIR . WidgetManager::ExtPath() . $this->m_data['path'];
    }
Пример #6
0
 /**
  * Get path
  * @return string
  */
 public function getPath()
 {
     $cur_path = $this->m_data['path'];
     if (0 === strpos($cur_path, WWW_DIR)) {
         return $cur_path;
     }
     foreach (WidgetManager::ExtPath() as $path) {
         if (file_exists($file = WWW_DIR . $path . $this->m_data['path'])) {
             return $file;
         }
     }
 }
 public function actionColumnsManage($model_id, $widget_id)
 {
     $model = ActiveRecord::model($model_id);
     if (isset($_POST['columns'])) {
         file_put_contents(WidgetManager::getVisibleColumnsFilePath($model_id, $widget_id), serialize(explode(',', $_POST['columns'])));
         if (isset($_GET['redirect'])) {
             $this->redirect(base64_decode($_GET['redirect']));
         }
     }
     $visible_columns = WidgetManager::getVisibleColumns($model_id, $widget_id);
     $hidden_columns = array();
     $attributes = array_keys($model->attributeLabels());
     $visible_columns = array_intersect($visible_columns, $attributes);
     foreach ($attributes as $attribute) {
         if ($attribute == 'captcha') {
             continue;
         }
         if (in_array($attribute, $visible_columns)) {
             continue;
         }
         $hidden_columns[] = $attribute;
     }
     $this->render('columnsManage', array('visible_columns' => $visible_columns, 'hidden_columns' => $hidden_columns, 'model' => $model));
 }
Пример #8
0
    /**
     * Creates a new user.
     *
     * @param array
     *    $p_values The user data
     *
     * @param bool
     *    TRUE on success, FALSE on failure
     */
    public function create($p_values = null)
    {
        global $LiveUserAdmin;

        if (is_array($p_values)) {
            $p_values['time_created'] = strftime("%Y-%m-%d %H:%M:%S", time());
        }
        foreach ($p_values as $key => $value) {
            if ($key == 'UName') {
                $key = 'handle';
            }
            $values[$key] = $value;
        }
        $values['perm_type'] = 1;

        if ($permUserId = $LiveUserAdmin->addUser($values)) {
            $filter = array('container' => 'perm',
                            'filters' => array('perm_user_id' => $permUserId));
            $user = $LiveUserAdmin->getUsers($filter);
            $p_values['Id'] = $user[0]['auth_user_id'];
	    $p_values['Password'] = $user[0]['passwd'];
            $this->fetch($p_values);
            if (function_exists("camp_load_translation_strings")) {
                camp_load_translation_strings("api");
            }
            $logtext = getGS('User account "$1" ($2) created', $this->m_data['Name'], $this->m_data['UName']);
            Log::Message($logtext, null, 51);

            if ($user['0']['reader'] == 'N') {
                // add default widgets
                require_once dirname(__FILE__) . '/Extension/WidgetManager.php';
                WidgetManager::SetDefaultWidgets($p_values['Id']);
            }

            return true;
        }

        return false;
    } // fn create
Пример #9
0
    public function initColumns()
    {
        $button_column_exists = false;

        $attributes_columns = $this->columns;
        foreach ($attributes_columns as $i => $data)
        {
            if (isset($data['class']))
            {
                if ($data['class'] == 'CButtonColumn')
                {
                    $button_column_exists = true;
                }

                unset($attributes_columns[$i]);
            }
        }

        if (!$attributes_columns)
        {
            $model = $this->filter;

            $attributes = WidgetManager::getVisibleColumns(get_class($model), $this->id);

            if ($attributes)
            {
                foreach ($attributes as $i => $attribute)
                {
                    $this->addColumn(
                        array(
                            'name'  => $attribute,
                            'value' => '$data->value("' . $attribute . '")',
                            'type'  => 'raw',
                            'filter' => $model->filter($attribute),
                        ),
                        $i
                    );
                }
            }
        }

        if (!$button_column_exists)
        {
            $this->addColumn(array('class' => 'CButtonColumn'), count($this->columns) + 1);
        }

        if ($this->many_many_sortable)
        {
            $this->addColumn(array(
                'class' => 'ext.sortable.ManyManySortableColumn',
                'header'=> t('Сортировка')
            ), -1);
        }

        if ($this->sortable)
        {
            $this->addColumn(array(
                'class' => 'ext.sortable.SortableColumn',
                'header'=> t('Сортировка')
            ), -1);
        }

        if ($this->mass_removal)
        {
            $this->addColumn(array(
                'class'               => 'CCheckBoxColumn',
                'header'              => "<input type='checkbox' class='object_checkboxes'>",
                'selectableRows'      => 2,
                'checkBoxHtmlOptions' => array(
                    'class'    => 'object_checkbox'
                )
            ));
        }

        parent::initColumns();
    }
Пример #10
0
 /**
  * Caches and returns list of all possible actions 
  */
 public static function loadRoleActionList()
 {
     if (!ca_user_roles::$s_action_list) {
         $o_config = Configuration::load();
         $o_actions_config = Configuration::load(__CA_CONF_DIR__ . '/user_actions.conf');
         $vo_datamodel = Datamodel::load();
         $va_raw_actions = $o_actions_config->getAssoc('user_actions');
         // expand actions that need expanding
         foreach ($va_raw_actions as $vs_group => $va_group_info) {
             $va_new_actions = array();
             if (!is_array($va_group_info["actions"])) {
                 $va_group_info["actions"] = array();
             }
             foreach ($va_group_info["actions"] as $vs_action_key => $va_action) {
                 if (is_array($va_action["expand_types"]) && strlen($va_action["expand_types"]["table"]) > 0) {
                     $t_instance = $vo_datamodel->getInstanceByTableName($va_action["expand_types"]["table"], true);
                     if (method_exists($t_instance, "getTypeList")) {
                         $va_type_list = $t_instance->getTypeList();
                         foreach ($va_type_list as $vn_type_id => $va_type) {
                             $vs_descr_app = str_replace("%t", "&quot;" . $va_type["name_singular"] . "&quot;", $va_action["expand_types"]["description_appendix"]);
                             $vs_label_app = str_replace("%t", "&quot;" . $va_type["name_singular"] . "&quot;", $va_action["expand_types"]["label_appendix"]);
                             $va_new_actions[$vs_action_key . "_type:{$t_instance->tableName()}:{$va_type["idno"]}"] = array("description" => $va_action["description"] . " " . $vs_descr_app, "label" => $va_action["label"] . " " . $vs_label_app);
                         }
                     }
                 }
             }
             $va_group_info["actions"] = array_merge($va_group_info["actions"], $va_new_actions);
         }
         if (is_array($va_raw_plugin_actions = ApplicationPluginManager::getPluginRoleActions())) {
             $va_raw_actions['plugins'] = array('label' => 'Plugin actions', 'description' => '', 'actions' => $va_raw_plugin_actions);
         }
         if (is_array($va_raw_widget_actions = WidgetManager::getWidgetRoleActions())) {
             $va_raw_actions['widgets'] = array('label' => 'Widget actions', 'description' => '', 'actions' => $va_raw_widget_actions);
         }
         $va_flattened_actions = array();
         foreach ($va_raw_actions as $vs_group => $va_group_actions_info) {
             if (!is_array($va_group_actions_info['actions'])) {
                 $va_group_actions_info['actions'] = array();
             }
             $va_flattened_actions = array_merge($va_flattened_actions, $va_group_actions_info['actions']);
         }
         ca_user_roles::$s_action_list = array('raw' => $va_raw_actions, 'flattened' => $va_flattened_actions);
     }
     return ca_user_roles::$s_action_list;
 }
Пример #11
0
function caGetDashboardWidgetHTML($po_request, $pn_column)
{
    $o_dashboard_manager = DashboardManager::load($po_request);
    $va_widget_list = $o_dashboard_manager->getWidgetsForColumn($pn_column);
    foreach ($va_widget_list as $vn_i => $va_widget_info) {
        print "<div class='portlet' id='dashboardWidget_{$pn_column}_{$vn_i}'>";
        print caNavLink($po_request, '<img src="' . $po_request->getThemeUrlPath() . '/graphics/spacer.gif" width="16" height="16" border="0" title="' . _t("remove widget from dashboard") . '">', 'dashboardRemoveWidget', '', 'Dashboard', 'removeWidget', array('widget' => $va_widget_info['widget'], 'widget_id' => $va_widget_info['widget_id']));
        if ($o_dashboard_manager->widgetHasSettings($va_widget_info['widget'])) {
            print "<a href='#' class='dashboardWidgetSettingsButton' onclick='jQuery(\"#content_" . $va_widget_info['widget_id'] . "\").load(\"" . caNavUrl($po_request, '', 'Dashboard', 'getSettingsForm') . "\", { widget_id: \"" . $va_widget_info['widget_id'] . "\" }); return false;'><img src='" . $po_request->getThemeUrlPath() . "/graphics/spacer.gif' width='16' height='16' border='0' title='" . _t("Modify settings for this widget") . "'></a>";
        }
        print '<div class="portlet-header">' . WidgetManager::getWidgetTitle($va_widget_info['widget']) . '</div>';
        print '<div class="portlet-content" id="content_' . $va_widget_info['widget_id'] . '">' . $o_dashboard_manager->renderWidget($va_widget_info['widget'], $va_widget_info['widget_id'], $va_widget_info['settings']) . '</div>';
        print '</div>';
    }
}
Пример #12
0
 /** 
  * Returns list of user actions defined by all widgets
  *
  * @return array List of user actions keyed by action code
  */
 public static function getWidgetRoleActions()
 {
     $va_actions = array();
     $o_config = Configuration::load();
     $vs_base_widget_dir = $o_config->get('dashboard_widgets');
     $va_widget_dirs = WidgetManager::getWidgetNames();
     foreach ($va_widget_dirs as $vs_widget_dir) {
         if (!file_exists($vs_base_widget_dir . '/' . $vs_widget_dir . '/' . $vs_widget_dir . 'Widget.php')) {
             continue;
         }
         require_once $vs_base_widget_dir . '/' . $vs_widget_dir . '/' . $vs_widget_dir . 'Widget.php';
         $vs_widget_classname = $vs_widget_dir . 'Widget';
         $va_actions = array_merge($va_actions, call_user_func(array($vs_widget_classname, 'getRoleActionList')));
     }
     return $va_actions;
 }
Пример #13
0
 /**
  * Set default widgets for all existing users (called after install/upgrade)
  * @return void
  */
 public static function SetDefaultWidgetsAll()
 {
     // do only once
     if (SystemPref::Get(self::SETTING) != NULL) {
         return;
     }
     SystemPref::Set(self::SETTING, time());
     // set widgets per user
     $users = (array) $GLOBALS['controller']->getHelper('service')->getService('user')->findBy(array('is_admin' => 1));
     foreach ($users as $user) {
         WidgetManager::SetDefaultWidgets($user->getUserId());
     }
 }
 *
 * This program is free software; you may redistribute it and/or modify it under
 * the terms of the provided license as published by Whirl-i-Gig
 *
 * CollectiveAccess is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTIES whatsoever, including any implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 *
 * This source code is free and modifiable under the terms of 
 * GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
 * the "license.txt" file for details, or visit the CollectiveAccess web site at
 * http://www.CollectiveAccess.org
 *
 * ----------------------------------------------------------------------
 */
$o_widget_manager = $this->getVar('widget_manager');
$va_widget_list = $o_widget_manager->getWidgetNames();
print caFormTag($this->request, 'addWidget', 'caWidgetManagerForm', null, 'post', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true));
?>
		<input type="hidden" name="widget" value="" id='caWidgetManagerFormWidgetValue'/>
<?php 
foreach ($va_widget_list as $vs_widget_name) {
    $va_status = WidgetManager::checkWidgetStatus($vs_widget_name);
    if (!$va_status["available"]) {
        continue;
    }
    print "<a href='#' onclick='jQuery(\"#caWidgetManagerFormWidgetValue\").val(\"{$vs_widget_name}\"); jQuery(\"#caWidgetManagerForm\").submit();'><img src='" . $this->request->getThemeUrlPath() . "/graphics/buttons/addwidget.jpg' style='height:10px; width:10px; border:0px;'> " . $o_widget_manager->getWidgetTitle($vs_widget_name) . "</a><br/>\n";
    print "<div id='widgetDescription'>" . $o_widget_manager->getWidgetDescription($vs_widget_name) . "</div>";
}
?>
	</form>
Пример #15
0
    /**
     * Set default widgets for all existing users (called after install/upgrade)
     * @return void
     */
    public static function SetDefaultWidgetsAll()
    {
        require_once dirname(__FILE__) . '/../User.php';

        // do only once
        if (SystemPref::Get(self::SETTING) != NULL) {
            return;
        }

        SystemPref::Set(self::SETTING, time());

        // set widgets per user
        $users = (array) User::GetUsers();
        foreach ($users as $user) {
            WidgetManager::SetDefaultWidgets($user->getUserId());
        }
    }
Пример #16
0
<?php

require_once dirname(dirname(__FILE__)) . '/db_connect.php';
require_once dirname(dirname(__FILE__)) . '/classes/Input.php';
require_once dirname(dirname(__FILE__)) . '/classes/Extension/WidgetContext.php';
require_once dirname(dirname(__FILE__)) . '/classes/Extension/WidgetManager.php';
camp_load_translation_strings('home');
camp_load_translation_strings('articles');
camp_load_translation_strings('api');
camp_load_translation_strings('extensions');
camp_load_translation_strings('globals');
// install default widgets for admin
WidgetManager::SetDefaultWidgetsAll();
// add title
echo camp_html_breadcrumbs(array(array(getGS('Dashboard'), '')));
if (!SystemPref::get('stat_ask_time')) {
    SystemPref::set('stat_ask_time', 0);
}
if (!SystemPref::get('installation_id')) {
    $installationId = sha1($_SERVER['SERVER_ADDR'] . $_SERVER['SERVER_NAME'] . mt_rand());
    SystemPref::set('installation_id', $installationId);
}
$request_only = false;
if (!SystemPref::get('support_send') && SystemPref::get('stat_ask_time') <= time() && empty($_SESSION['statDisplayed'])) {
    $statUrl = $Campsite['WEBSITE_URL'] . '/admin/support/popup';
    $request_only = true;
    ?>
<a style="display: none;" id="dummy_stat_link" href="<?php 
    echo $statUrl;
    ?>
"></a><?php 
Пример #17
0
<div class="links">
    <a href="<?php 
echo $Campsite['WEBSITE_URL'];
?>
/admin/" title="<?php 
echo $translator->trans('Go to dashboard', array(), 'home');
?>
"><?php 
echo $translator->trans('Go to dashboard', array(), 'home');
?>
</a>
</div>

<ul id="widgets">
    <?php 
foreach (WidgetManager::GetAvailable() as $widget) {
    ?>
    <li>
        <h3><?php 
    echo $widget->getTitle();
    ?>
</h3>
        <p><a href="#<?php 
    echo $widget->getExtension()->getId();
    ?>
" class="add"><?php 
    echo $translator->trans('Add to dashboard', array(), 'home');
    ?>
</a>&nbsp;</p>
        <p><?php 
    echo $translator->trans($widget->getDescription());
Пример #18
0
 private function handleForm(Zend_Form $form, Staff $staff)
 {
     if ($this->_request->isPost() && $form->isValid($this->_request->getPost())) {
         try {
             $this->repository->save($staff, $form->getValues());
             $this->_helper->entity->getManager()->flush();
             // TODO bad design, redirect should not be here.
         } catch (\PDOException $e) {
             $this->_helper->flashMessenger(array('error', getGS("Could not save user '\$1'. Please make sure it doesn't already exist", $this->_request->getPost('username'))));
             $this->_helper->redirector->gotoSimple('add', 'staff', 'admin');
         } catch (\InvalidArgumentException $e) {
             if ($e->getMessage() == 'email') {
                 $this->_helper->flashMessenger(array('error', getGS("Could not save user with e-mail address '\$1'. Please make sure it doesn't already exist", $this->_request->getPost('email'))));
             }
             $this->_helper->redirector->gotoSimple('add', 'staff', 'admin');
         } catch (\Exception $e) {
             $this->_helper->flashMessenger(array('error', getGS("Changing user type would prevent you to manage users. Aborted.")));
             $this->_helper->redirector->gotoSimple('edit', 'staff', 'admin', array('user' => $staff->getId()));
         }
         // add default widgets for new staff
         if ($this->_getParam('action') == 'add') {
             WidgetManager::SetDefaultWidgets($staff->getId());
         }
         $this->_helper->flashMessenger(getGS('Staff member saved.'));
         $this->_helper->redirector->gotoSimple('edit', 'staff', 'admin', array('user' => $staff->getId()));
     }
 }
Пример #19
0
 /**
  * Set default widgets for all existing users (called after install/upgrade)
  * @return void
  */
 public static function SetDefaultWidgetsAll()
 {
     $preferencesService = \Zend_Registry::get('container')->getService('system_preferences_service');
     // do only once
     if ($preferencesService->get(self::SETTING) != NULL) {
         return;
     }
     $preferencesService->set(self::SETTING, time());
     // set widgets per user
     $users = (array) $GLOBALS['controller']->getHelper('service')->getService('user')->findBy(array('is_admin' => 1));
     foreach ($users as $user) {
         WidgetManager::SetDefaultWidgets($user->getUserId());
     }
 }