Esempio n. 1
0
 function getConfiguration()
 {
     if ($this->_conf) {
         return $this->_conf;
     } else {
         $this->_db->setQuery("SELECT * FROM #__adsmanager_config");
         $this->_conf = $this->_db->loadObject();
         $params = json_decode($this->_conf->params);
         if ($params != null) {
             foreach ($params as $name => $value) {
                 $this->_conf->{$name} = $value;
                 if ($name == 'max_width_m' && $value == '/') {
                     $this->_conf->{$name} = 300;
                 }
                 if ($name == 'max_height_m' && $value == '/') {
                     $this->_conf->{$name} = 200;
                 }
             }
         }
         if (!isset($this->_conf->display_nb_categories_per_row)) {
             $this->_conf->display_nb_categories_per_row = 3;
         }
         if (!isset($this->_conf->globalfilter_user)) {
             $this->_conf->globalfilter_user = 1;
         }
         if (!isset($this->_conf->globalfilter_fieldname)) {
             $this->_conf->globalfilter_fieldname = "";
         }
         if (!isset($this->_conf->crontype)) {
             $this->_conf->crontype = "cron";
         }
         if (!isset($this->_conf->wizard_form)) {
             $this->_conf->wizard_form = 0;
         }
         if (version_compare(JVERSION, '1.6.0', 'ge')) {
             if (JRequest::getVar('c', '') != "configuration") {
                 $user = JFactory::getUser();
                 $groups = JHTMLAdsmanagerUserGroups::getUserGroup($user->id);
                 if (isset($this->_conf->nb_images_groups)) {
                     foreach ($this->_conf->nb_images_groups as $key => $group) {
                         if (in_array($group, $groups)) {
                             $this->_conf->nb_images = $this->_conf->nb_images_value[$key];
                         }
                     }
                 }
                 if (isset($this->_conf->nb_ads_by_user_groups)) {
                     foreach ($this->_conf->nb_ads_by_user_groups as $key => $group) {
                         if (in_array($group, $groups)) {
                             $this->_conf->nb_ads_by_user = $this->_conf->nb_ads_by_user_value[$key];
                         }
                     }
                 }
             }
         }
         return $this->_conf;
     }
 }
Esempio n. 2
0
 /**
  * Return in an array the usergroups of the user
  * 
  * @param int $userid
  * @return Array
  */
 public static function getUserGroup($userid)
 {
     if (self::$groups == null) {
         $db = JFactory::getDBO();
         $db->setQuery('SELECT group_id FROM #__user_usergroup_map
                         WHERE user_id = ' . (int) $userid);
         $groups = $db->loadColumn();
         if ($groups == null) {
             $groups = array();
         }
         self::$groups = $groups;
     }
     return self::$groups;
 }
Esempio n. 3
0
 /**
  * Return in a array all the authorised categories
  * 
  * @param string $mode
  * @return Array
  */
 public static function getAuthorisedCategories($mode)
 {
     //If the static variable is already set, we directly return it
     if (self::$listcategories == null) {
         $user = JFactory::getUser();
         $userGroups = array();
         //If the user is a guest, we authorise the public group
         //else we return the authorised group of the user
         if ($user->guest) {
             $userGroups[] = 1;
         } else {
             $userGroups = JHTMLAdsmanagerUserGroups::getUserGroup($user->id);
         }
         $authorisedCategories = array();
         $modelCategories = new AdsmanagerModelCategory();
         $categories = $modelCategories->getCategories(false);
         foreach ($categories as $category) {
             $labelUsergroups = 'usergroups' . $mode;
             $catUserGroups = $category->{$labelUsergroups};
             $catUserGroupsArray = explode(',', $catUserGroups);
             //We load the usergroups authorised by the category
             //If there is no usergroups saved, we authorised the category
             if ($catUserGroups != '') {
                 //We compare the authorised usergroups of the two array
                 //And save in a array the matching value.
                 foreach ($userGroups as $userGroup) {
                     if (array_search($userGroup, $catUserGroupsArray) !== false) {
                         if (array_search($category->id, $authorisedCategories) === false) {
                             $authorisedCategories[] = $category->id;
                         }
                     }
                 }
             } else {
                 if (array_search($category->id, $authorisedCategories) === false) {
                     $authorisedCategories[] = $category->id;
                 }
             }
         }
         self::$listcategories = $authorisedCategories;
     }
     return self::$listcategories;
 }
<?php 
echo $tabs->endPanel();
echo $tabs->startPanel(JText::_('ADSMANAGER_TAB_CONTACT'), "contact-page");
?>
<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
    <?php 
if (version_compare(JVERSION, '1.6.0', 'ge')) {
    ?>
	<tr>
		<td><?php 
    echo JText::_('ADSMANAGER_SHOW_CONTACT');
    ?>
</td>
		<td>
		<?php 
    echo JHTMLAdsmanagerUserGroups::getUserGroups('show_contact[]', empty($this->conf->show_contact) ? '-1' : explode(',', $this->conf->show_contact), array('multiple' => 'multiple', 'size' => 10));
    ?>
		</td>
		<td><?php 
    echo JText::_('ADSMANAGER_SHOW_CONTACT_LONG');
    ?>
</td>
	</tr>
    <?php 
}
?>
	<tr>
		<td><?php 
echo JText::_('ADSMANAGER_DISPLAY_FULLNAME');
?>
</td>
    ?>
</td>
<td>
    <?php 
    echo JText::_('ADSMANAGER_ACL_DESC');
    ?>
</td>
</tr>
<tr>
<td><?php 
    echo JText::_('ADSMANAGER_TH_ACL_WRITE');
    ?>
</td>
<td>
<?php 
    echo JHTMLAdsmanagerUserGroups::getUserGroups('usergroupswrite[]', empty($this->row->usergroupswrite) ? '-1' : explode(',', $this->row->usergroupswrite), array('multiple' => 'multiple', 'size' => 10));
    ?>
</td>
<td>
    <?php 
    echo JText::_('ADSMANAGER_ACL_DESC');
    ?>
</td>
</tr>
<?php 
}
?>
</table>
<input type="hidden" name="id" value="<?php 
echo @$this->row->id;
?>
Esempio n. 6
0
                <?php 
}
?>
                <?php 
if (version_compare(JVERSION, '1.6', 'ge')) {
    ?>
                <tr>
                <th><?php 
    echo JText::_('ADSMANAGER_USERGROUPS_WRITE');
    ?>
</th>
                </tr>
                <tr>
                <td>
                <?php 
    echo JHTMLAdsmanagerUserGroups::getUserGroups('options_common_usergroups_write[]', empty($this->options->usergroups_write) ? '-1' : explode(',', $this->options->usergroups_write), array('multiple' => 'multiple', 'size' => 10));
    ?>
                </td>
                <td>
                    <?php 
    echo JText::_('ADSMANAGER_ACL_DESC');
    ?>
                </td>
                </tr>
                <?php 
}
?>
		  </table>
  		</td></tr>
  </table>
  <input type="hidden" name="fieldid" value="<?php 
    /**
     * Return if a user can see the ads contact
     * 
     * @return boolean
     */
	static public function checkRightContact(){
        
        //If the static variable is already set, we directly return it
        if (self::$showContact == null) {
            $user = JFactory::getUser();
            
            $conf = TConf::getConfig();
            
            $userGroups = array();

            if(version_compare(JVERSION, '1.6', 'ge')) {
                //If the user is a guest, we authorise the public group
                //else we return the authorised group of the user
                if($user->guest)
                    $userGroups[] = 1;
                else
                    $userGroups = JHTMLAdsmanagerUserGroups::getUserGroup($user->id);

                $authorisedContact = false;
                $allowedContacts = explode(',', $conf->show_contact);

                foreach ($userGroups as $userGroup) {
                    if(array_search($userGroup, $allowedContacts) !== false){
                        $authorisedContact = true;
                    }
                }

                self::$showContact = $authorisedContact;
            } else {
                self::$showContact = true;
            }
        }
        return self::$showContact;
    }