Esempio n. 1
0
 /**
  * It creates a new ModelMoreedit object class ir if it has been created
  * before, it return the previous object
  *
  * @access public
  * @since 3.0
  * @return ModelMoreedit
  */
 public static function newInstance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Esempio n. 2
0
/**
 * Blocks item_add page if limit is reached, only if web_user_logged_in
 */
function moreedit_item_add()
{
    if (!osc_is_web_user_logged_in()) {
        return true;
    }
    if (osc_get_preference('max_ads_week', 'moreedit') > 0) {
        $total_per_week = ModelMoreedit::newInstance()->ads_per_week(osc_logged_user_id());
        if ($total_per_week >= osc_get_preference('max_ads_week', 'moreedit')) {
            osc_add_flash_error_message(__('Sorry, you have reached your maximun number of ads per week allowed', 'moreedit'));
            header("location: " . osc_base_url());
            exit;
        }
    }
    if (osc_get_preference('max_ads_month', 'moreedit') > 0) {
        $total_per_month = ModelMoreedit::newInstance()->ads_per_month(osc_logged_user_id());
        if ($total_per_month >= osc_get_preference('max_ads_month', 'moreedit')) {
            osc_add_flash_error_message(__('Sorry, you have reached your maximun number of ads per month allowed', 'moreedit'));
            header("location: " . osc_base_url());
            exit;
        }
    }
}