/**
  * set or unset the availability of widgets for a user and a role
  * @param string $role Group of widget for which the availability must be updated
  * @param boolean $availability Is the $role must be set as available or not
  */
 public function updateWigetsAvailabilityForRole($role, $availability)
 {
     $file = MyWidgets::getFileByRight($role);
     if ($file) {
         $data = new Doctrine_Parser_Yml();
         $array = $data->loadData($file);
         $q = Doctrine_Query::create()->update('MyWidgets p')->set('p.is_available', '?', $availability)->where('p.user_ref = ?', $this->user_ref);
         $list_group_name = array();
         foreach ($array as $widget => $array_values) {
             $list_group_name[] = $array_values['group_name'];
         }
         $q->wherein('p.group_name', $list_group_name)->execute();
     }
 }
Esempio n. 2
0
 public function executeReloadContent(sfWebRequest $request)
 {
     $w = new MyWidgets();
     $w->setCategory($request->getParameter('category'));
     return $this->renderComponent($w->getComponentFromCategory(), $request->getParameter('widget'), array('eid' => $request->getParameter('eid', null), 'table' => $w->getTableFromCategory($request->getParameter('table')), 'level' => $this->getUser()->getAttribute('db_user_type')));
 }
Esempio n. 3
0
    ?>
          <a href="#" class="widget_close" ><?php 
    echo image_tag('widget_close.png', 'alt=Close');
    ?>
</a>
      <?php 
}
?>
    </div>
    <span>
      <?php 
if ($category != 'boardwidget' && !$read_only) {
    ?>
          
        <?php 
    echo help_ico(MyWidgets::getHelpIcon($category, $widget), $sf_user);
    ?>
      <?php 
}
?>
      <?php 
echo __($title);
?>
    </span>
  </div>
  <div class="widget_content <?php 
if (!$is_opened) {
    ?>
hidden<?php 
}
?>
Esempio n. 4
0
 /**
  * function to add all user's widgets in my_widgets table
  * use user id and db_user_type
  * @return the number of widget added
  */
 public function addUserWidgets($thisWidget = null)
 {
     $count_widget = 0;
     $array_right = Users::getTypes(array('db_user_type' => self::ADMIN));
     foreach ($array_right as $key => $right) {
         $file = MyWidgets::getFileByRight($key);
         if ($file) {
             $data = new Doctrine_Parser_Yml();
             $array = $data->loadData($file);
             foreach ($array as $widget => $array_values) {
                 if ($thisWidget) {
                     if (isset($thisWidget['category']) && $thisWidget['category'] != $array_values['category']) {
                         continue;
                     } elseif (isset($thisWidget['name']) && isset($thisWidget['category']) && ($thisWidget['name'] != $array_values['group_name'] || $thisWidget['category'] != $array_values['category'])) {
                         continue;
                     }
                 }
                 $pref = new MyWidgets();
                 $array_values['user_ref'] = $this->getId();
                 $pref->fromArray($array_values);
                 $pref->setIsAvailable(true);
                 try {
                     $pref->save();
                     $count_widget++;
                 } catch (Doctrine_Exception $ne) {
                 }
             }
         }
     }
     return $count_widget;
 }